nginx和django高并发优化

为了调节性能做了如下优化:

增加nginx的worker process数量

uwsgi

[uwsgi]

chdir = /root/seo/seom/
socket = 127.0.0.1:8528
vacuum=True
module=SeoM.wsgi
daemonize = /var/log/seo-uwsgi.log

processes = 10 
threads = 10 
max-requests=10000
listen = 512 ---> linux kernel limit, try to increase it
buffer-size = 32768
  • 调节socket最大链接数
    sysctl -a | grep somaxconn --> 128
    -->sysctl -w net.core.somaxconn=1024

  • 优化nginx
    查看链接数
    netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
    netstat -n -p -t

vi /etc/sysctl.conf 编辑文件,加入以下内容:
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_fin_timeout = 30 然后执行
sysctl -p

你可能感兴趣的:(nginx和django高并发优化)