Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web application very slow in Tomcat 7

I implemented a web application to start the Tomcat service works very quickly, but spending hours and when more users are entering is getting slow (up to 15 users approx.).

Checking RAM usage statistics (20%), CPU (25%)

Server Features:

  • RAM 8GB
  • Processor i7
  • Windows Server 2008 64bit
  • Tomcat 7
  • MySql 5.0
  • Struts2
  • -Xms1024m
  • -Xmx1024m
  • PermGen = 1024
  • MaxPernGen = 1024

I do not use Web server, we publish directly on Tomcat.

Entering midnight slowness is still maintained (only 1 user online)

The solution I have is to restart the Tomcat service and response time is again excellent.

Is there anyone who has experienced this issue? Any clue would be appreciated.

like image 202
Alejo Rlz Avatar asked Sep 13 '12 16:09

Alejo Rlz


People also ask

Why is Tomcat so slow?

For Tomcat itself to run slow would mean that the VM it's running in was severely starved for resources. So, for example, if Tomcat is running slow, you should check to make sure that the machine that Tomcat is running on has enough physical RAM that it isn't thrashing virtual memory.


1 Answers

I experienced a very slow stock Tomcat dashboard on a clean Centos7 install and found the following cause and solution:

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.

Source: https://www.digitalocean.com/community/questions/tomcat-8-5-9-restart-is-really-slow-on-my-centos-7-2-droplet

Fix it by adding the following configuration option to your tomcat.conf or (preferred) a custom file into /tomcat/conf/conf.d/:

JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom"
like image 106
Piemol Avatar answered Sep 20 '22 05:09

Piemol