技术解析
一个 30ms 的只读一次 mysql 的接口,在 4 核 8G 的服务器上并发多少正常,为什么我并发只有 100 左右 uwsgi 配置:
listen = 4096 chdir = /home/××××× module = app_django.wsgi master = true processes = 4 socket = /××××××/app.sock limit-as = 65535 max-request = 65535 memory-report = true enable-threads = true chmod-socket = 666 vacuum = true
nginx 配置:
user nginx; worker_processes 4; worker_cpu_affinity 0001 0010 0100 1000;
error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid;
daemon off; events { use epoll; worker_connections 65535; multi_accept off; }
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
美国服务器sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
default_type application/octet-stream;
upstream django2 {
server unix:///home/×××/app.sock;
}
server {
listen 80;
server_name _;
location /m {
uwsgi_pass django2;
include /home/×××/uwsgi_params;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
# Settings for a TLS enabled server.
#gzip on;
}