Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Persistent Connections Slow to Respond to Extra Requests

7:24 am on Apr 25, 2007 (gmt 0)

New User

5+ Year Member

joined:Apr 25, 2007
votes: 0

Hey, I'm writing a program to test the performance of apache (we had a similar problem with lighttpd), and I keep running into a problem with persistent connections. We make single request, like:

GET fileName HTTP/1.1
Host: server:80
Keep-Alive: 300
Connection: keep-alive

And we get a response back. We then make another, similar, request on the same connection, and we get a response back, but there's a huge delay in-between sending our request and getting the response for the second request.

To give you an idea of the times:

request 1: sent at 0 ms, received at 1 ms
request 2: sent at 1 ms, received at 41 ms
request 3: sent at 41 ms, received at 81 ms
request 4: sent at 81 ms, received at 121 ms

And we see this 40 ms delay all throughout. Clearly it doesn't take that long to deliver the file, so we're not sure what gives...why the delay? Just FYI, we're testing on a high-bandwidth, low-latency network.

Also, we do HTTP pipelining, and when we send all these requests at once on one connection, we get the response back extremely quick--we're just not sure why the 40 ms or so delay between requests on the same persistent connection and not on the pipelined connection. There's almost no lag between the machine, so we're not sure what's up.

Not sure if it's a setting we can change, something we're doing wrong, or something apache's just doing slowly.


7:46 pm on Apr 25, 2007 (gmt 0)

Junior Member

10+ Year Member

joined:Nov 29, 2002
votes: 0

What is the round-trip (ping) time from the client to the server?

This looks like your difference. The client may also be doing some waiting, especially if it has no way of knowing when one request is finished -- is your HTTPd sending Content-length, and expires HTTP headers?

12:44 am on Apr 26, 2007 (gmt 0)

New User

5+ Year Member

joined:Apr 25, 2007
votes: 0

The ping is <1ms. We also get the entire first file usually in less than 1 ms or 2 ms, and there's no difference in the size.

This is a C program we are writing (not a typical client). We get the first response back fine (as we do for all of the other ones...they are just slow). We know we are waiting on the Unix read command. Maybe it doesn't write() immediately on our second request, but it does return (not sure how Unix handles it) and there's no delay for the first request.

Any other suggestions?



Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members