axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Fernandez Martinez, Alejandro" <>
Subject Axis performance reading socket input stream
Date Wed, 29 Oct 2003 09:39:23 GMT
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;
                    inp = (InputStream) currentMessage ;
                    ByteArrayOutputStream  baos = new
                    buf = new byte[4096];
                    int len ;
                    while ( (len =,0,4096)) != -1 )
                        baos.write( buf, 0, len );
                    buf = baos.toByteArray();
                  if(inp != null && 
                    currentMessage instanceof
org.apache.axis.transport.http.SocketInputStream )    
                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.

                int available = inputStream.available();
                // only read available bytes
                buf = new byte[available];
            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.

View raw message