Wild ass guess: It's outside your code. Possibly outside your control.
Could be several things:
* Depending on the VM - garbage collection can take a bit.
* Reading a file - with multiple users - you may have file locking (or
blocking/queuing/serializing) at some internal level within the appserver.
I'm convinced, somewhere, the multiple processes are being seralized
(instead of being done in parallel).
What other things are within the process/timing loop? Your code takes a
HttpServletRequest - are you going through a webserver? (IIS, Apache) to an
AppServer and then a database server? Is everything on the same box or
several boxes? Single CPU or multiple CPU's. Does you AppServer already
have the request threads created before your test - or are they being
instantiated during the test. Lots of questions - problem could be within
many components - so you need to tell us what components are with the loop.
-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet API
Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of John Zink
Sent: Thursday, August 02, 2001 8:07 AM
To: [EMAIL PROTECTED]
Subject: Re: Servlet Performance
Here is my new code:
protected String getFile(HttpServletRequest req) throws IOException {
String file = null;
DataInputStream in = null;
String contentType = req.getContentType();
in = new DataInputStream(req.getInputStream());
int formDataLength = req.getContentLength();
byte dataBytes[] = new byte[formDataLength];
int bytesRead = 0;
for (int totalBytesRead = 0;
totalBytesRead < formDataLength;
totalBytesRead += bytesRead)
bytesRead = in.read(dataBytes, totalBytesRead, formDataLength);
file = new String(dataBytes);
in.close();
return file;
}
I did some timings with passing a 28k http/xml request to the servlet and
noticed some strange results. Running 1 client in a loop of 25 times the
routine will take anywhere from 25 milliseconds to 7 seconds to execute. If
I put some stress on it (5 virtual users) the routine can take from 25
milliseconds to 20 seconds to execute.
Any ideas ????
On Wed, 1 Aug 2001 09:31:52 -0500, Christopher K. St. John
<[EMAIL PROTECTED]> wrote:
>John Zink wrote:
>>
>> Could you send me an example of StringBuffer pooling ?
>> I am not quite sure what you mean.
>>
>
>
> Forget the StringBuffer pooling (with a modern JVM it
>probably won't help much anyway). Your problem is that
>touching bytes/chars one at a time is deadly slow. Fix
>your reader to read/append arrays. Bonus points if you
>can make the array as big as the request (so you end
>up with a single read and a single append). You can
>muck around further trying for more performance, but
>fix the one-char-at-a-time problem first. (If you've
>already done that, never mind :-)
>
>
>--
>Christopher St. John [EMAIL PROTECTED]
>DistribuTopia http://www.distributopia.com
>
>___________________________________________________________________________
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html