大网数据广告活动
服务器运维问答

What is meant by TCP connection pooling?

· 52CE 我爱测

Why is creating a new TCP connection regarded as expensive? was the question I had in mind when another one came to my mind. What exactly is meant by keeping a TCP connection alive and what is meant by caching a connection throug…

问题原文

原帖链接 · user2250246 · CC BY-SA 4.0

Why is creating a new TCP connection regarded as expensive? was the question I had in mind when another one came to my mind.

What exactly is meant by keeping a TCP connection alive and what is meant by caching a connection through connection pools? (I do understand thread pools concept but confused with "connection" part of connection pools).

Isn't the TCP traffic supposed to flow through a number of Internet-based IPs (computers and routers etc) before it reaches the destination? If that is so, then what does a connection even mean? Does it refer to the path established once for TCP traffic and re-using the connection means that the same path is used again and again until some IPs in that path are not available anymore?

已采纳解答

原帖链接 · Tero Kilkanen · CC BY-SA 4.0

TCP connection is initialised by a three-way handshake, where both ends of the connection agree on sequence numbers they are using for packets they send.

When three-way handshake is finished, the connection is in ESTABLISHED state, which means that data can flow bi-directionally.

The individual TCP segments in the connection can take different paths between the sender and receiver. All TCP cares about is that both ends have the same idea about connection state.

Keepling TCP connection alive means that the connection is kept in ESTABLISHED state, even though there is no immediate need to transmit any data via the connection. Web servers use connection pools to manage these open connections to clients.

A practical example of keeping TCP connection open. A website visitor loads https://www.example.com.

  1. The browser opens a TCP connection to https://www.example.com port 443.
  2. The browser does TLS handshake with the web server.
  3. The browser sends GET / request to the web server and server sends response page back.
  4. The browser leaves TCP connection open with the web server.

Visitor then browses through the page and clicks on https://www.example.com/example link.

  1. Now browser can send GET /example request directly to the web server, re-using the existing TCP connection and TLS transport.

If the web server / client did not keep TCP connection open, browser would have to repeat steps 1 and 2 for the second HTTPS request.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-09-07)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。