Friday, June 10, 2011

Power of AccessLog & Tomcat Valve configuration

In recent past we faced quite a performance issues resulting in different modes of collecting performance statistics from web server. One of the handy tool was web server access logs, all I had to do is configure my webserver to write access logs. It dumps all the requested information (URL, Timestamp & Even roundtrip/response time of a request), How cool... with zero additional code you get response time of each request.

Link below details of access log configuration on tomcat, this could vary depending on the type of webserver used. But every webserver would have a access log by default.
http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html#Access_Log_Valve

All different types of valves supported by Tomcat, most useful of it all is "Request Dumper" valve (dumps all request detail) & "Access Log" Valve.
http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html#Request_Dumper_Valve

Example, below configuration (%D %T) will log response time for a request & timestamp of the request.


Valve className="org.apache.catalina.valves.AccessLogValve" prefix="localhost_access_log." suffix=".txt" pattern="%D %T"

Lot of tools can help you analyze the access logs & provide more insight of the usage response time etc.
http://www.nltechno.com/awstats/awstats.pl?config=destailleur.fr

Conclusion: We all know it's mandatory for a web server to have an access log,
but the good part is this can greatly ease performance study & tune
your web application.

No comments: