简体   繁体   English

将保持活动状态杀死异步连接

[英]Will Keep-alive kill async connection

Let's say my browser post a HTTP request to a domain, before this request finish, another different request (by ajax) was send to the same domain. 假设我的浏览器将HTTP请求发布到域,在此请求完成之前,另一个不同的请求(通过ajax)被发送到了同一域。 Since the first request still on-going and not yet terminated, will that mean second request will have to wait first request to finish in order to use the persistent connection that being used by first request? 由于第一个请求仍在进行且尚未终止,这是否意味着第二个请求将必须等待第一个请求完成才能使用第一个请求使用的持久连接? If it is, how to prevent this? 如果是,该如何预防? If I have a long streaming connection in the first request, does that mean second request will need to hang around for long time? 如果第一个请求中的流连接很长,那是否意味着第二个请求将需要长时间徘徊?

(Let's assume the maximum persistent connection for browser is one. Actually I don't really understand what this "max persistent connection" does. Does it mean when the persistent connection is over the maximum number, the rest of connection will become non-persistent ? Confusing...) (让我们假设浏览器的最大持久连接数是一个。实际上我并不真正理解“最大持久连接数”的作用。这是否意味着当持久连接超过最大数量时,其余连接将变为非持久性连接。 ?令人困惑...)

Can anyone explain this? 谁能解释一下?

Since the first request still on-going and not yet terminated, will that mean second request will have to wait first request to finish in order to use the persistent connection that being used by first request? 由于第一个请求仍在进行且尚未终止,这是否意味着第二个请求将必须等待第一个请求完成才能使用第一个请求使用的持久连接?

No. The two requests are still asynchronous and in parallel (unless the server limits this). 否。这两个请求仍然是异步且并行的(除非服务器对此进行了限制)。

HTTP Keep Alive only means that they are faster because both requests can use the same connection, especially when pipelining them. HTTP保持活动状态仅表示它们速度更快,因为两个请求都可以使用相同的连接,尤其是在管道化时。

However, if there is no pipelining, the browser could also decide to open a second connection for the second request, instead of waiting for the first request to finish and reusing its connection. 但是,如果没有流水线,浏览器还可以决定为第二个请求打开第二个连接,而不是等待第一个请求完成并重新使用其连接。 See Under what circumstances will my browser attempt to re-use a TCP connection for multiple requests? 请参阅在什么情况下我的浏览器将尝试对多个请求重新使用TCP连接? for details. 有关详细信息。

I don't really understand what this "max persistent connection" does. 我真的不明白这种“最大持续连接”的作用。 Does it mean when the persistent connection is over the maximum number, the rest of connection will become non-persistent? 这是否意味着当持久连接超过最大数量时,其余连接将变为非持久连接?

No. When the limit is reached, new requests will have to wait until a connection from the pool becomes usable again. 不会。达到限制后,新请求将必须等待,直到池中的连接再次可用为止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM