每个TCP连接的HTTP请求数 [英] Number of HTTP requests per TCP connection

查看:214
本文介绍了每个TCP连接的HTTP请求数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于每个TCP连接,客户端可以向服务器发出的HTTP请求数量是否有限制?我写了一个python脚本,该脚本应该打开一个TCP连接并发送10个类似的HTTP post请求.前5个请求会立即发送,但是后5个请求会花费很长时间(这些请求非常健壮,需要服务器花费超过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)

这使我相信每个TCP连接最多5个请求,并且客户端在发送更多请求之前正在等待服务器响应这些请求.如果是这样,那么在哪里/如何设置/定义此限制?

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?

推荐答案

您正在将每个连接的请求总数与连接内的未解决请求数混合在一起.后者仅与HTTP管道传输有关,在HTTP管道中,客户端一次发送多个请求,即在相同的TCP连接内发送第二个请求之前,不等待第一个请求的响应.据我所知,现代浏览器均未默认启用HTTP流水线,另请参见

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.

关于TCP连接内的HTTP请求总数-没有限制.但是客户端和服务器将在一些不活动状态后或者甚至在固定数量的请求后关闭连接(取决于浏览器和服务器).而且,如果有很多请求要执行,大多数浏览器将使用多个TCP连接发送所有这些请求,而不是对所有请求使用单个连接.尽管创建新的TCP连接会产生最初的成本,但是如果浏览器可以将所有这些请求分发到多个连接中,则可以快速赎回它.

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.

这篇关于每个TCP连接的HTTP请求数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆