Wolfgang,

Please allow me to point out that your comparison is not completely accurate. Apache 
benchmark (I assume) uses HTTP GET requests, whereas your test application uses HTTP 
POST requests. Besides, you should have used HttpCliet's simple (non-multithreaded) 
connection manager to be on an equal footing with AB. I have tweaked your application 
somewhat (See the source code attached below) and that is what I got

1000 HTTP GET requests against local Tomcat 4.1.27 running on RedHat 9, Sun JRE 1.4.2

HttpClient (Sun JRE 1.4.2): 3.209 [sec] vs Apache Benchmark: 0.910710 [sec]

I personally find these results reasonable, taking into account that AP (most likely) 
does not provide any sort of an object model unlike HttpClient.

Bottom line, the trick there was to disable stale connections check which is terribly 
taxing in terms of performance for massive amount of very short requests.

Cheers

Oleg

-------------------------------------------------------------------------------------------
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.SimpleHttpConnectionManager;
import org.apache.commons.httpclient.methods.GetMethod;


public class HTTPBug {
        
        protected HttpClient client;
        protected String url;
        
        public static void main(String[] args) throws Exception {
                int k=0;

                int size = 1000;
                if (args.length > k) size = Integer.parseInt(args[k++]);
                
                String url = "/examples/servlet/HelloWorldExample";
                if (args.length > k) url = args[k++];
                
                SimpleHttpConnectionManager conn_manager = new 
SimpleHttpConnectionManager(); 
                HttpClient client = new HttpClient(conn_manager);
                conn_manager.setConnectionStaleCheckingEnabled(false);
                client.getHostConfiguration().setHost("localhost", 8080);
                
                long start = System.currentTimeMillis();
                for (int i=0; i<size; i++) {
                        GetMethod method = new GetMethod(url);
                        client.executeMethod(method);
                        method.releaseConnection();
                }
                long end = System.currentTimeMillis();
                System.out.println("total time (ms): " + (end - start));
                System.out.println("time (ms) per request: " + ((end - start)/size));
        }

}
-------------------------------------------------------------------------------------------
<snip>
Server Software:        Apache
Server Hostname:        localhost
Server Port:            8080

Document Path:          /examples/servlet/HelloWorldExample
Document Length:        405 bytes

Concurrency Level:      1
Time taken for tests:   0.910710 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    990
Total transferred:      557950 bytes
HTML transferred:       405000 bytes
Requests per second:    1098.04 [#/sec] (mean)
Time per request:       0.911 [ms] (mean)
Time per request:       0.911 [ms] (mean, across all concurrent requests)
Transfer rate:          597.34 [Kbytes/sec] received
<snip>
-------------------------------------------------------------------------------------------


-----Original Message-----
From: Wolfgang Hoschek [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 14, 2003 1:14 AM
To: [EMAIL PROTECTED]
Cc: Wolfgang Hoschek
Subject: Performance HTTPClient vs. ab


I am planning on sending and receiving MANY (tens of tousands) small 
SOAP-like serial messages over the same persistent HTTP 1.1 connection, 
using a single client and thread (nothing fancy there). A High 
performance, low latency http library would be ideal.

HTTPClient performance seems devastating wrt. ab (apache benchmark): 
4300 requests/sec vs. 20 requests/sec, i.e. two orders of magnitute 
difference, no matter what options I try with HTTPClient.

Source code to reproduce and full data is attached.
If anyone is interested, please let me know what I'm doing wrong, 
reproduce the effect and/or post working code that performs well in your 
experience.

ab -k -n 10000 http://localhost:8080/discofish/HelloWorldServlet > /tmp/out

Requests per second:    4313.48 [#/sec] (mean)

(For more data see full output in attachment)


[doggy /home/oliver/g5/users/hoschek] time disco-java.sh 
gov.lbl.dsd.discofish.client.HTTPBug 100 
http://localhost:8080/discofish/HelloWorldServlet > /tmp/out2

real    0m4.876s
user    0m0.550s
sys     0m0.060s

--> Requests per second:    20.0

(For more data see full output in attachment)

Similar performance gap on static HTML pages (no need to use a servlet).

Environment: httpclient-2.0rc1, jdk-1.4.2, tomcat-4.1.27 (server.xml out 
of the box), 2GHz Pentium IV, Redhat 8.0.

Thanks,
Wolfgang.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to