5

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

Michael
  • 325
  • 5
  • 13
  • you want NIO for static resources. –  Mar 07 '11 at 19:31
  • Have a look here, it has been discussed already: http://stackoverflow.com/questions/654701/how-much-slower-is-serving-static-content-from-tomcat – mindas Mar 07 '11 at 21:43
  • @mindas: That's not really the issue here, the normal throughput of Tomcat is more than acceptable. I'm trying to ascertain why the occasional piece of content takes and extremely long time. – Michael Mar 08 '11 at 08:53

2 Answers2

4

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).

Tomasz Nurkiewicz
  • 774
  • 1
  • 6
  • 10
2

Have an apache web server before the tomcat and serve images and js from there. Route the rest of traffic to tomcat through proxy settings or ajp.

Vinod R
  • 121
  • 3
  • 2
    All the whitepapers I've read indicate that when on a single server, the combination is slower. In any case, Tomcat is supposed to cache small files - the data start-time seen in the example (90+ seconds) is more than just HTTP throughput, surely? – Michael Mar 07 '11 at 17:04
  • I want to make sure if you have verified with an apache in the front. In my experience found that apache was much more efficient for static content. – Vinod R Mar 07 '11 at 17:25