uWSGI listen queue 队列溢出的问题

By 水木神風 at 2017-02-08 • 0人收藏 • 2279人看过

如果没有设置uwsgi的--listen,如果sysctl -a | grep net.core.somaxconn发现net.core.somaxconn=128。

那你使用uwsgi启动的服务,单机最大支持并发数为100*(启动的uwsgi进程数)。

如果启动进程为4个,则最大并发只能支持400,这样会在uwsgi的log日志中出现错误uWSGI listen queue of socket 4 full。

同时,nginx对应也会出现错误***** upstream time out。



修补措施:

  1. 修改系统参数

vim /etc/sysctl.conf

vm.swappiness = 0

net.ipv4.neigh.default.gc_stale_time=120

net.ipv4.conf.all.rp_filter=0

net.ipv4.conf.default.rp_filter=0

net.ipv4.conf.default.arp_announce = 2

net.ipv4.conf.all.arp_announce=2

net.ipv4.tcp_max_tw_buckets = 5000

net.ipv4.tcp_syncookies = 1

net.ipv4.tcp_max_syn_backlog = 1024

net.ipv4.tcp_synack_retries = 2

net.ipv4.conf.lo.arp_announce=2

fs.file-max=65535

net.ipv4.tcp_fin_timeout = 30

net.ipv4.tcp_tw_reuse = 1

net.ipv4.tcp_tw_recycle = 1

net.ipv4.ip_local_port_range = 1024 65000

net.ipv4.tcp_max_syn_backlog = 65536

net.ipv4.tcp_max_tw_buckets = 20000

net.ipv4.route.gc_timeout = 100

net.ipv4.tcp_syn_retries = 1

net.ipv4.tcp_synack_retries = 1

net.core.somaxconn = 65535

net.core.netdev_max_backlog = 262144

net.ipv4.tcp_timestamps = 0

net.ipv4.tcp_max_orphans = 262144


 执行 sysctl -p 重新load参数设置,这样会立即生效,并且以后重新启动机器也会生效。

2.设置uwsgi启动的--listen 1024.

这样 你的机器并发数就可以得到一个很大的提升。


登录后方可回帖