2

I recently switched my web application from running via an embedded Jetty instance to a standalone Tomcat instance. Everything is mapped appropriately, and Tomcat begins to serve up content.

However, my application makes about 20 AJAX POST requests at once to the server (to load various page elements). This worked fine on Jetty, however Tomcat services the first few, then returns the following response for the next one or two:

Server: Apache-Coyote/1.1
Content-Length: 0
Date: Fri, 09 Jul 2010 02:13:37 GMT

And then continues servicing requests, returning "blank" responses every 3rd or 4th request. I dont think its a problem with the way the request is being handled, since a) it works on Jetty and b) on refreshing the page, some requests that didnt complete before complete, and some that did complete before no longer complete.

I am wondering if Tomcat is unhappy that it is being bombarded with many requests from the same IP in the same second. Does anyone know how to fix this?

EDIT: I believe the issue is related to threading. If I make my servlets implement SingleThreadModel, the issue goes away (of course this is deprecated and sub-optimal, I will try and figure out where the real issue is). I believe the reason why it worked in Jetty was because I was using an embedded Jetty instance (as opposed to a standalone Jetty instance), which must have only been using a single thread inside my Application.

Erin Drummond
  • 5,347
  • 6
  • 35
  • 41
  • Just a sanity check, but if you run tomcat with the -verbose:gc command line switch, do you see it spending tons of times in GC? Is there any chance it is approaching it's memory limit (XMX) and ready to blow up? If all those are okay, we can look at changing your tomcat parameters to serve more pages per second – bwawok Jul 09 '10 at 02:31
  • It doesnt appear to be, however I have discovered that the issue appears to be related to threading – Erin Drummond Jul 09 '10 at 03:45

1 Answers1

0

EDIT: I believe the issue is related to threading. If I make my servlets implement SingleThreadModel, the issue goes away

Likely you're assigning request and/or session scoped data as instance variable of the servlet.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555