1

Is there a limit to the number of HTTP requests a client can makes to the server per TCP connection? I wrote a python script that is supposed to open a TCP connection and send 10 similar HTTP post requests. The first 5 requests are sent immediately, however the last 5 take a really long time (these are very beefy requests that take the server more than 1 min to respond)

This leads me to believe that 5 requests in the max per TCP connection and the clients is waiting for the server to respond to these requests before sending anymore requests. If this is true, then where/how is this limit set/defined?

Alex K.
  • 171,639
  • 30
  • 264
  • 288
SivaDotRender
  • 1,581
  • 4
  • 21
  • 37
  • 1
    This will depend on the configuration of the server, assuming you are specifying keep-alive for pipelining – Alex K. Aug 04 '15 at 14:34
  • 1
    It may also depend on the client (for instance, it may limit the number of concurrent requests to the same hostname), but hard to tell without any code. – robertklep Aug 04 '15 at 14:36
  • He can probably squirt as many requests as he likes down a single TCP connection which is what he appears to have, the socket wont care about concurrency – Alex K. Aug 04 '15 at 14:48
  • Unfortunately I did not write the client side code and I do not have the authorization to share it. From what I can see from the python script, there are no limitations on the number of HTTP requests on the client side code per TCP connection. If it helps, the Server is an nginx server running with default configurations. – SivaDotRender Aug 04 '15 at 14:53

1 Answers1

3

You are mixing the total number of requests per connection with the number of outstanding requests inside a connection. The latter is only relevant for HTTP Pipelining where the clients sends multiple requests at once, i.e does not wait for the response of the first request before sending the second request inside the same TCP connection. As far as I know none of the modern browsers enables HTTP Pipelining by default, see also https://www.chromium.org/developers/design-documents/network-stack/http-pipelining.

As for the total number of HTTP requests inside a TCP connection - there is no limit. But clients and server will close the connection after some inactivity or even after a fixed number of requests (depending on browser and server). And if there are lots of requests to do most browsers will use multiple TCP connections to send all these requests instead of using a single connection for all requests. And while there is an initial cost to create a new TCP connection it redeems fast if the browser then can distribute all these requests to multiple connections.

Steffen Ullrich
  • 114,247
  • 10
  • 131
  • 172