users@jersey.java.net

[Jersey] Is Jersey/Jersey client duplicating requests

From: peterjca <p.cameron_at_monitormedia.co.uk>
Date: Mon, 11 Jul 2011 04:44:59 -0700 (PDT)

I'm having an interesting problem which occurs randomly under heavy load. I'd
appreciate some advice/help.

I'm developing a Java web application and deploying to Tomcat 7. The web app
uses Spring 3.05 and has a RESTful interface implemented with Jersey 1.8. It
only runs on my machine and nothing else talks to it apart from a Java
integration test on my machine which throws data at it.

The app is a "black box" which is interested in counting combinations of
inputs from forms. Randomly, the counts in the database would be wrong --
never ever less than expected, but always one or two more than expected. In
other words, it's not as if there is a race condition and updates are being
overwritten since the counts are never less than they should be. The
back-end is thoroughly thread-safe.

My test harness generates 10 batches of loads. Each batch is submitted
concurrently, and each request within a batch is submitted serially with a
1/10 second delay. (The batch sizes are: 5372, 801, 3005, 637, 9311, 313,
1024, 777, 412, 1201.) The harness uses the Jersey client API to post data.

I incorporated the following diagnostics in my application:

o various statistics using JMX beans and atomic integer counts
o atomic integer request count in the test harness
o http header in each request containing the unique request count

These diagnostics show that the test harness always sends out the correct
number of requests but that the web app receives more requests than the test
harness is sending. I put a BitSet into the Jersey resource endpoint (which
receives each post), large enough for the total number of requests, and set
the appropriate bit corresponding to the unique count I pass as an http
header. Debugging shows that I sometimes receive more than one request with
the same count.

Now, there are two resource end-points in use during the testing: one
(FormSubmissionResource) consumes posted data (/service/submitData) and the
other (RatingResource) performs a calculation (/service/calculate). The
harness repeatedly:

1. Posts a number of times to FormSubmissionResource.
2. Issues a get to RatingResource.

If I don't issue anything to the RatingResource then the app behaves
correctly. If both resources are in play then sending a get to
RatingResource somehow results in FormSubmissionResource randomly receiving
more posts than is sent out -- as mentioned above, the extra posts are
duplicates since they contain the same request count in the header.

Any idea what is going on?

cheers,
Peter


--
View this message in context: http://jersey.576304.n2.nabble.com/Is-Jersey-Jersey-client-duplicating-requests-tp6570645p6570645.html
Sent from the Jersey mailing list archive at Nabble.com.