什么是“tcp-backlog"?在 redis.conf 中 [英] What's "tcp-backlog" in redis.conf

查看:94
本文介绍了什么是“tcp-backlog"?在 redis.conf 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm confused by tcp-backlog in redis.conf:

# 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完整连接队列"的大小(三次握手完成,描述的是什么此处) 或不完整的连接队列"?

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

如果它的意思是完整的连接队列",那我为什么要提高限制不完整连接队列大小的tcp_max_syn_backlog?

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

推荐答案

tcp-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) 调用的第二个参数传递.

tcp-backlog is the size of complete connection queue. In fact, Redis passes this configuration as the second parameter of the listen(int s, int backlog) call.

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

@GuangshengZuo already had a good answer for this question. So I'll focus on the other one.

如果它的意思是完整的连接队列",那我为什么要提高 tcp_max_syn_backlog 来限制不完整的连接队列的大小?

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

引用您提到的文档:

该实现使用了两个队列,一个SYN队列(或不完整连接队列)和一个accept队列(或完整连接队列).状态为 SYN RECEIVED 的连接被添加到 SYN 队列,然后当它们的状态更改为 ESTABLISHED 时,即当收到 3 次握手中的 ACK 数据包时,将移动到接受队列.顾名思义,accept 调用的实现只是为了消费来自接受队列的连接.在这种情况下,listen 系统调用的 backlog 参数决定了接受队列的大小.

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.

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

We can see that items in complete connection queue are moved from the incomplete connection queue.

如果你有一个大的 somaxconn 和一个小的 tcp_max_syn_backlog,那么你可能没有足够的项目移动到完整的连接队列,并且完整的连接队列可能永远不会满.许多请求可能已经从第一个队列中删除,然后才有机会移动到第二个队列.

If you have a large somaxconn with a small tcp_max_syn_backlog, then you might NOT have enough items to be moved to the complete connection queue, and the complete connection queue might never be full. Many requests might have already been dropped from the first queue before they have the chance to be moved to the second.

所以只提高 somaxconn 的值可能不起作用.你必须把它们都养起来.

So only raise the value of somaxconn might NOT work. You have to raise both of them.

这篇关于什么是“tcp-backlog"?在 redis.conf 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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