Tomcat – Java: Tomcat slow serving static files

javatomcat

I'm running an instance of Apache Tomcat (5.5) on a Windows 2008 platform. I think I'm seeing an issue related to concurrent file access / locking.

When the number of concurrent HTTP threads is increased beyond the default setting (150), I see (using a site monitoring tool) an increasing number of 'unnatural' delays when serving some static content (.js .gif .png etc). By this, I mean that the server takes 20 seconds plus before starting to send or taking 30 seconds to serve a small (2KiB) file.

When Tomcat is busy (serving over 300 threads), CPU usage averages around 50-60% and disk usage is around 10-30mbps.

Are there any tools I can use for Java to establish whether this is the case? Would the Tomcat APR / Apache Native Library potentially resolve this?

Alternatively, is there anything else I should be looking into?

Screenshot of site analysis tool:
enter image description here

Best Answer

Tomcat 7 supports serving static files outside of the WAR. See here (point 4.) Have you tried it?

Can you confirm that it's the Tomcat that generates such a delay (for instance using Tomcat's access log)? It shouldn't be hard to correlate slowly downloaded file with entry in access log on the server side.

What are the HTTP threads doing during the test? It would be amazing to dump stack traces when this phenomenon happens. If you see that some resource takes excessively long time to download, just perform dump and find the guilty thread (with tuned access log you can print the thread name).

Related Topic