Fresh Tomcat takes loong time to start up

October 7, 2014 13.8k views

So I'm new to digitalOcean.
I began with ubuntu server and ran an tomcat installation on it according to this tutorial

And server start up takes really long time ("INFO: Server startup in 518366 ms"). I have one app on it that only has index.html file in it, just for testing.

What could be the cause of this? Is the Lowest bugget option on digitalocean really that slow?

  • The same for me. It's not that it is slow when starting, it's that it takes too long to even start doing something.

  • Any luck on this? I'm seeing this even with a bigger droplet with a fresh tomcat7 install.

  • I didn't find any solution and since I'm just trying things out i could live with the longer wait.. although it's annoying.

  • Try to install haveged - slow startup may occur when entropy pool runs dry.

    by Salvatore LaMendola
    Entropy is important, and haveged is an application that can provide your system with more of it.
  • @juriyfoboss Could you also comment why would Tomcat need to use entropy pool on fresh intall?

  • I'm getting about a 15 minute delay on both Tomcat install (fresh start) and even some service restarts. I've tried this even on larger droplet size (8GB RAM), not just the small size with the same issue.

    Any progress or suggestions on this? (haveged did not work)

  • Just wanted to update this thread if anyone comes across it. The solution was kind of hidden amongst comments and on a hard to find page:

    *On the the JAVA_OPTS line, add the following: -Djava.security.egd=file:/dev/./urandom"

    Also - interestingly, after testing more with this, it seems that installing haveged (just apt-get install haveged with it's default settings) does work as well. (without the additional line above).

    (and using haveged is better for security due to the loss of true entropy on non-blocking /dev/urandom)

  • +1. saved my time. i am using $5 plan.

    apt-get install haveged
  • +1.
    thanks for this @juriyfoboss.

    haveged worked for me like a charm.

    apt-get install haveged
6 Answers

Modify JAVA_OPTS in catalina.sh to get this up quickly. It didn't seem to take effect under /etc/default/tomcat7 for me. What is important is the java.security.egd line. (Update the library path as needed.)

JAVA_OPTS="-Djava.library.path=/usr/local/apr/lib -Djava.security.egd=file:/dev/./urandom -Djava.awt.headless=true -Xmx1024m -XX:MaxPermSize=512m -XX:+UseConcMarkSweepGC"

Another way is changing the option directly on the file. Check this: Check this: http://stackoverflow.com/questions/26431922/tomcat7-starts-too-late-on-ubuntu-14-04-x64-digitalocean. This resolved my problem.

This worked for me apt-get install haveged. It took me minutes for my page to reload for a restart.

This was hugely helpful. Solved the problem instantly just by installing haveged with defaults.
Thanks @juriyfoboss .

just installing haveged on Centos did not solve the issue, you have to start haveged service.

+1 to installing haveged. Thanks bro!

Have another answer? Share your knowledge.