You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Fernandez Martinez, Alejandro" <a....@ibermatica.com> on 2003/10/29 10:39:23 UTC
Axis performance reading socket input stream
Hi folks,
I have been making some performance tests for Axis, using a local and a
remote machine as SOAP server: just sending a small SOAP message a number of
times. I can give you the specifics if you want; for the moment, suffice to
say that Axis was making about 3 requests/second over a local 100 MBit
ethernet. Quite insufficient for any real-world application.
For comparison, I have also load-tested GLUE from The Mind Electric. I was
getting between 100 and 500 req/s with the same setup.
After looking for the bottleneck, the class org.apache.axis.SOAPPart seems
to be the culprit. Specificially, this snippet from SOAPPart.getAsBytes():
// Assumes we don't need a content length
try {
InputStream inp = null;
byte[] buf = null;
try{
inp = (InputStream) currentMessage ;
ByteArrayOutputStream baos = new
ByteArrayOutputStream();
buf = new byte[4096];
int len ;
while ( (len = inp.read(buf,0,4096)) != -1 )
baos.write( buf, 0, len );
buf = baos.toByteArray();
}finally{
if(inp != null &&
currentMessage instanceof
org.apache.axis.transport.http.SocketInputStream )
inp.close();
}
setCurrentForm( buf, FORM_BYTES );
log.debug("Exit: SOAPPart::getAsBytes");
return (byte[])currentMessage;
}
catch( Exception e ) {
log.error(Messages.getMessage("exception00"), e);
}
It seems that this was stalling for a long time (from zero to 300 ms). A
quick hack resulted in much better performance: now I'm getting from 10 to
100 requests/second.
try
{
int available = inputStream.available();
// only read available bytes
buf = new byte[available];
inputStream.read(buf);
}
catch (IOException e)
{
log.error(Messages.getMessage("exception00"), e);
}
It might have some problems though:
- It works OK for HTTP transport, but it might not be flexible
enough for other protocols,
- and for big messages it might not work at all.
It would probably better to read until available is 0 or -1, so that there
is no network stalling.
I wonder if this issue has come up before, and if you would be interested in
a patch for this.
Un saludo,
Alex Fernández.
Re: Axis performance reading socket input stream
Posted by Davanum Srinivas <di...@yahoo.com>.
Alex,
Can you please zip and send the whole test case? (add it to bugzilla? -
http://ws.apache.org/axis/bugs.html)
Thanks,
dims
--- "Fernandez Martinez, Alejandro" <a....@ibermatica.com> wrote:
> Hi folks,
>
> I have been making some performance tests for Axis, using a local and a
> remote machine as SOAP server: just sending a small SOAP message a number of
> times. I can give you the specifics if you want; for the moment, suffice to
> say that Axis was making about 3 requests/second over a local 100 MBit
> ethernet. Quite insufficient for any real-world application.
>
> For comparison, I have also load-tested GLUE from The Mind Electric. I was
> getting between 100 and 500 req/s with the same setup.
>
> After looking for the bottleneck, the class org.apache.axis.SOAPPart seems
> to be the culprit. Specificially, this snippet from SOAPPart.getAsBytes():
> // Assumes we don't need a content length
> try {
> InputStream inp = null;
> byte[] buf = null;
> try{
> inp = (InputStream) currentMessage ;
> ByteArrayOutputStream baos = new
> ByteArrayOutputStream();
> buf = new byte[4096];
> int len ;
> while ( (len = inp.read(buf,0,4096)) != -1 )
> baos.write( buf, 0, len );
> buf = baos.toByteArray();
> }finally{
> if(inp != null &&
> currentMessage instanceof
> org.apache.axis.transport.http.SocketInputStream )
> inp.close();
> }
> setCurrentForm( buf, FORM_BYTES );
> log.debug("Exit: SOAPPart::getAsBytes");
> return (byte[])currentMessage;
> }
> catch( Exception e ) {
> log.error(Messages.getMessage("exception00"), e);
> }
>
> It seems that this was stalling for a long time (from zero to 300 ms). A
> quick hack resulted in much better performance: now I'm getting from 10 to
> 100 requests/second.
>
> try
> {
> int available = inputStream.available();
> // only read available bytes
> buf = new byte[available];
> inputStream.read(buf);
> }
> catch (IOException e)
> {
> log.error(Messages.getMessage("exception00"), e);
> }
>
> It might have some problems though:
> - It works OK for HTTP transport, but it might not be flexible
> enough for other protocols,
> - and for big messages it might not work at all.
> It would probably better to read until available is 0 or -1, so that there
> is no network stalling.
>
> I wonder if this issue has come up before, and if you would be interested in
> a patch for this.
>
> Un saludo,
>
> Alex Fern�ndez.
>
=====
Davanum Srinivas - http://webservices.apache.org/~dims/