2. Feb. 2009

So you have a wonderful java-servlet and you have a stable and reasonable fast application server like tomcat? But sometimes you have performance breakdowns.

  • Sometimes the application seems to be frozen.
  • Sometimes you just want to know what the hell
    is going on with your application.

So the best way is to say:
“Please my little tomcat, tell me how do you feel right now?”

And if you choose the right method you will get some answers.
The good news ahead it isn’t very difficult to get the information.

You just have to enable the tomcat console. And furthermore you should enable the printout of the garbage collects.
(type “java -X” to get the right gc options for your java-version – normally something like verbose:gc. I will show you in detail in another article)

Just edit the tomcat-users.xml File.

You have to add the roles: manager and admin and add a user and a password that meets your needs. Invent your own username and password and keep it secret. Because userid and password are not encrypted (if you do not explicitly configure https as protocol) you should keep in mind that this is no high sophisticated security.

Tomcat Monitoring

Nevertheless – save your tomcat-users.xml file and restart tomcat. If your tomcat listens on the standard port (8080) give the manager console a try:

http://yourserver-adress:8080/manager/html

You will be prompted for a username and password – if you can remember the values you had put in the tomcat-user.xml file – go on and put them in. So you can see the console – not very exciting – thats true. Here you can just see how many sessions are currently active in an application . And if you want to have fun and you are !not the responsible person for this service you can easily stop an application within the tomcat.

But to be more serious now choose the link in the upper right corner (Server Status) and again the link in the upper right corner (Complete Server Status).
Or just enter:

http://yourserver-adress:8080/manager/status/all

Take some time to explore the page. Reload the page several times ñ look at how the connections fall and rise. Don’t forget to check the Memory is enough free memory left ? What is the state of the connections ñ are there any connections left. How many threads are busy? How many spare threads do you have? Perhaps you have to adjust the values in the server.conf file.

Can you imagine that it is very easy to get this values extracted and in a “cvs”-file on a regular basis ? So you can get historical values – But that is subject for an own article.