sockets - 调整大量 XMPP 用户的 TCP 设置

标签 sockets tcp xmpp ubuntu-12.04

我读到用于处理大量并发用户的默认 TCP 设置不合适。所以我调整了其中的一些设置,我在下面添加了文件。

我现在遇到的问题:

  • 用户连接每 30-40 秒就会断开一次。然后用户自动重新连接到用户。我已经使用默认的 tcp 设置部署了完全相同的服务器,并且没有断开连接。

  • 当用户失去 wi-fi 连接且 tcp 连接未关闭时。我减少了 keepalive settins,但这似乎不起作用。用户失去了 wi-fi 连接,他仍然被认为在线,但他肯定是离线的。我是否正确应用 TCP keepalive 设置来解决不正常关闭的 TCP 连接问题?

`

#Increase system file descriptor limit
fs.file-max = 100000

# Discourage Linux from swapping idle processes to disk (default = 60)
vm.swappiness = 10

# Increase ephermeral IP ports
net.ipv4.ip_local_port_range = 10000 65000

# Increase Linux autotuning TCP buffer limits
# Set max to 16MB for 1GE and 32M (33554432) or 54M (56623104) for 10GE
# Don't set tcp_mem itself! Let the kernel scale it based on RAM.
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.core.rmem_default = 16777216
net.core.wmem_default = 16777216
net.core.optmem_max = 40960
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216

# Make room for more TIME_WAIT sockets due to more clients,
# and allow them to be reused if we run out of sockets
# Also increase the max packet backlog
net.core.netdev_max_backlog = 50000
net.ipv4.tcp_max_syn_backlog = 30000
net.ipv4.tcp_max_tw_buckets = 2000000
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 10

# Disable TCP slow start on idle connections
net.ipv4.tcp_slow_start_after_idle = 0

# If your servers talk UDP, also up these limits
net.ipv4.udp_rmem_min = 8192
net.ipv4.udp_wmem_min = 8192

# Disable source routing and redirects
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.all.accept_source_route = 0

# Log packets with impossible addresses for security
net.ipv4.conf.all.log_martians = 1
net.ipv4.tcp_keepalive_time = 60
net.ipv4.tcp_keepalive_intvl = 10
net.ipv4.tcp_keepalive_probes = 5`

最佳答案

如果您使用的是 openfire,那么您需要更改空闲连接策略设置

关于sockets - 调整大量 XMPP 用户的 TCP 设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23403490/

相关文章:

C# .Net Socket 保持事件时间?

iPhone/Android 实时通信、XMPP、原始 TCP?

iphone - XMPP在openfire服务器上检索公共(public)房间+ iphone SDK

Node.js 套接字同时发送和接收

python - Python套接字/端口转发

C—— socket 。客户端 : connect: No such file or directory

Linux TCP : packet segmentation?

c++ - 高效的数据包类型/传输协议(protocol)

java - 我的 tcp 客户端/服务器程序中没有写入任何值

linux - 无法在 Mac 上安装 ejabberd