gpt4 book ai didi

tcp - redis.conf 中的 "tcp-backlog"是什么

转载 作者:IT王子 更新时间:2023-10-29 05:55:48 29 4
gpt4 key购买 nike

我对 redis.conf 中的 tcp-backlog 感到困惑:

# TCP listen() backlog.
#
# In high requests-per-second environments you need an high backlog in order
# to avoid slow clients connections issues. Note that the Linux kernel
# will silently truncate it to the value of /proc/sys/net/core/somaxconn so
# make sure to raise both the value of somaxconn and tcp_max_syn_backlog
# in order to get the desired effect.
tcp-backlog 511

tcp-backlog 的大小是“完整连接队列”(三次握手完成,描述的是什么 here )还是“不完整连接队列”?

如果它意味着“完整的连接队列”那么我为什么要提高 tcp_max_syn_backlog 来限制不完整的连接队列的大小?

最佳答案

Is tcp-backlog the size of "complete connection queue" (three-way handshake complete, what is described here) or "incomplete connection queue"?

tcp-backlog完整连接队列的大小。事实上,Redis 将此配置作为 listen(int s, int backlog) 调用的第二个参数传递。

@GuangshengZuo 对这个问题已经有了很好的回答。所以我会专注于另一个。

If it means "complete connection queue" then why should I raise tcp_max_syn_backlog which limits the size of an incomplete connection queue?

引用您提到的文档:

The implementation uses two queues, a SYN queue (or incomplete connection queue) and an accept queue (or complete connection queue). Connections in state SYN RECEIVED are added to the SYN queue and later moved to the accept queue when their state changes to ESTABLISHED, i.e. when the ACK packet in the 3-way handshake is received. As the name implies, the accept call is then implemented simply to consume connections from the accept queue. In this case, the backlog argument of the listen syscall determines the size of the accept queue.

我们可以看到完整连接队列中的项目从不完整连接队列中移出。

如果你有一个大的 somaxconn 和一个小的 tcp_max_syn_backlog,那么你可能没有足够的项目被移动到 complete connection queue ,并且 complete connection queue 可能永远不会满。许多请求在有机会移动到第二个队列之前可能已经从第一个队列中删除。

所以只提高 somaxconn 的值可能行不通。你必须同时提高它们。

关于tcp - redis.conf 中的 "tcp-backlog"是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45807792/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com