kjkoster
17-07-2008, 11:04
Dear All,
Once an application is taken into production and it starts to run smoothly from a functional point of view, users generally start complaining about performance. There is always something. :-) I usually enable response time logging early on, so I can get a feel for which servlets and JSP pages are slow and which are fast. At the very least, it gives me the opportunity to say to my client: "yes, I know that the application is slow. The problem seems to be limited to BarServlet and foo.jsp, though". This sounds a whole lot better than: "Gee, is it? I'll have a look if I can find anything".
In Tomcat, you can edit server.xml and change the format used by the AccessLogValve. The AccessLogValve format is documented on the Tomcat (http://tomcat.apache.org/tomcat-6.0-doc/api/org/apache/catalina/valves/AccessLogValve.html) site. If you add a %D to the format string, Tomcat will replace it with the request's response time in milliseconds.
Here is the configuration of my access log valve. For this particular server I generate a separate log file, just for response times. Of course you can just add the %D to the log format of your configuration.
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="timing." suffix=".log"
pattern="%t %U %s %D" resolveHosts="false" />
The Apache web server offers the same thing, and the log format pattern also happens to be %D. This is documented on the Apache site (http://httpd.apache.org/docs/2.2/mod/mod_log_config.html#formats).
Here is the configuration I use in my Apache server. This is basically the default log format, with a %D inserted in a place where I can easily find it using awk(1) (http://nixdoc.net/man-pages/FreeBSD/awk.1.html):
LogFormat "%h %l %u %t \"%r\" %>s %b %D \"%{Referer}i\" \"%{User-Agent}i\"" combinedtime
CustomLog "/var/log/httpd-access.log" combinedtime
Be careful when interpreting the results. The time logged in Apache is in microseconds, where Tomcat logs in milliseconds. I was certainly confused the first time.
I then use Gnuplot (http://www.gnuplot.info/) to generate pretty graphs from the log files. I attached a sample file so you can see what it looks like.
Do you use response time logging for your applications and web servers? If not, in what way do you ensure that your page requests are fast enough?
Also, I would like to know how response time logging is enabled in other application servers, such as JBoss, OC4J and Orion.
Kees Jan
Once an application is taken into production and it starts to run smoothly from a functional point of view, users generally start complaining about performance. There is always something. :-) I usually enable response time logging early on, so I can get a feel for which servlets and JSP pages are slow and which are fast. At the very least, it gives me the opportunity to say to my client: "yes, I know that the application is slow. The problem seems to be limited to BarServlet and foo.jsp, though". This sounds a whole lot better than: "Gee, is it? I'll have a look if I can find anything".
In Tomcat, you can edit server.xml and change the format used by the AccessLogValve. The AccessLogValve format is documented on the Tomcat (http://tomcat.apache.org/tomcat-6.0-doc/api/org/apache/catalina/valves/AccessLogValve.html) site. If you add a %D to the format string, Tomcat will replace it with the request's response time in milliseconds.
Here is the configuration of my access log valve. For this particular server I generate a separate log file, just for response times. Of course you can just add the %D to the log format of your configuration.
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="timing." suffix=".log"
pattern="%t %U %s %D" resolveHosts="false" />
The Apache web server offers the same thing, and the log format pattern also happens to be %D. This is documented on the Apache site (http://httpd.apache.org/docs/2.2/mod/mod_log_config.html#formats).
Here is the configuration I use in my Apache server. This is basically the default log format, with a %D inserted in a place where I can easily find it using awk(1) (http://nixdoc.net/man-pages/FreeBSD/awk.1.html):
LogFormat "%h %l %u %t \"%r\" %>s %b %D \"%{Referer}i\" \"%{User-Agent}i\"" combinedtime
CustomLog "/var/log/httpd-access.log" combinedtime
Be careful when interpreting the results. The time logged in Apache is in microseconds, where Tomcat logs in milliseconds. I was certainly confused the first time.
I then use Gnuplot (http://www.gnuplot.info/) to generate pretty graphs from the log files. I attached a sample file so you can see what it looks like.
Do you use response time logging for your applications and web servers? If not, in what way do you ensure that your page requests are fast enough?
Also, I would like to know how response time logging is enabled in other application servers, such as JBoss, OC4J and Orion.
Kees Jan