Question

Tomcat 8.5.9 restart is really slow on my CentOS 7.2 droplet

I’ve got tomcat 8.5.9 installed on a CentOS 7.2 droplet. When I restart tomcat, with only the tomcat manager in the webapps directory, restarts take anywhere from 3 to 15 minutes, and sometimes even longer. Has anyone seen such behavior? Top doesn’t show much CPU or memory being consumed by Java. We’re running OpenJDK 1.8.0_111. Normal restart times with no webapps is a couple of seconds on other systems.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Andrew SB
DigitalOcean Employee
DigitalOcean Employee badge
December 20, 2016
Accepted Answer

Slow start up times for Tomcat are often related to Java’s SecureRandom implementation. By default, it uses /dev/random as an entropy source. This can be slow as it uses system events to gather entropy (e.g. disk reads, key presses, etc). As the urandom manpage states:

When the entropy pool is empty, reads from /dev/random will block until additional environmental noise is gathered.

One work around is to use /dev/urandom instead as it does not block. This is defined in your JAVA_OPTS That can be set in a number of places depending on how you set up Tomcat in the first place. It will usually be the init script or systemd service file used to start Tomcat.

-Djava.security.egd=file:/dev/./urandom

See this tutorial for more information.

Another option is to use haveged to generate more entropy. On CentOS, you can do so with:

yum install haveged
systemctl start haveged
systemctl enable haveged

For more information on how haveged works, check out this tutorial:

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.