HTTP Keep Alive时长与TCP超时时长的关系 [英] Relation between HTTP Keep Alive duration and TCP timeout duration

查看:17
本文介绍了HTTP Keep Alive时长与TCP超时时长的关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图了解 TCP/IP 和 HTTP 超时值之间的关系.这两个超时值是不同的还是相同的?大多数 Web 服务器允许用户通过一些配置来设置 HTTP Keep Alive 超时值.Web 服务器如何使用此值?这个值是否只是在底层 TCP/IP 套接字上设置的,即 HTTP Keep Alive 超时和 TCP/IP Keep Alive Timeout 是否相同?还是区别对待?

I am trying to understand the relation between TCP/IP and HTTP timeout values. Are these two timeout values different or same? Most Web servers allow users to set the HTTP Keep Alive timeout value through some configuration. How is this value used by the Web servers? is this value just set on the underlying TCP/IP socket i.e is the HTTP Keep Alive timeout and TCP/IP Keep Alive Timeout same? or are they treated differently?

我的理解是(可能不正确):无论配置的 HTTP Keep Alive 超时如何,Web 服务器都使用底层 TCP 套接字上的默认超时(即无限期)并创建一个工作线程来倒计时指定的 HTTP 超时间隔.当 Worker 线程为零时,它关闭连接.

My understanding is (maybe incorrect): The Web server uses the default timeout on the underlying TCP socket (i.e. indefinite) regardless of the configured HTTP Keep Alive timeout and creates a Worker thread that counts down the specified HTTP timeout interval. When the Worker thread hits zero, it closes the connection.

我的问题是关于两个超时持续时间之间的关系或差异,即当 HTTP 保持活动超时持续时间和 Web 服务器使用的 Socket (SO_TIMEOUT) 上的超时不同时会发生什么?我是否应该担心这两者是否相同?

My question is about the relation or difference between the two timeout durations i.e. what will happen when HTTP keep-alive timeout duration and the timeout on the Socket (SO_TIMEOUT) which the Web server uses is different? should I even worry about these two being same or not?

推荐答案

它们是两个独立的机制;名字纯属巧合.

They're two separate mechanisms; the name is a coincidence.

HTTP keep-alive(也称为持久连接)使 TCP 套接字保持打开状态,以便可以在不设置新连接的情况下发出另一个请求.

HTTP keep-alive (also known as persistent connections) is keeping the TCP socket open so that another request can be made without setting up a new connection.

TCP keep-alive 是一种定期检查,以确保连接仍然正常运行.它通常用于确保 NAT 盒(例如,DSL 路由器)不会忘记"内部和外部 ip/端口之间的映射.

TCP keep-alive is a periodic check to make sure that the connection is still up and functioning. It's often used to assure that a NAT box (e.g., a DSL router) doesn't "forget" the mapping between an internal and external ip/port.

这篇关于HTTP Keep Alive时长与TCP超时时长的关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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