nginx并发连接问题

bolbo 发布于 2015/08/26 22:51
阅读 459
收藏 0

我的服务器32G内存,8核CPU,安装的nginx,用webbench压测静态10000并发,太多失败,请问该如何优化?

以下是sysctl.conf:

net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
net.ipv4.tcp_max_tw_buckets = 12000
net.ipv4.tcp_sack = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_rmem = 4096 87380 4194304
net.ipv4.tcp_wmem = 4096 16384 4194304
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.core.netdev_max_backlog = 262144
net.core.somaxconn = 262144
net.ipv4.tcp_max_orphans = 3276800
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 1
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_fin_timeout = 1
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.ip_local_port_range = 1024 65535

以及nginx.conf

user  apps apps;

worker_processes 8;
error_log  /apps/logs/nginx/nginx_error.log  crit;
pid        /apps/logs/nginx/nginx.pid;
worker_rlimit_nofile 102400;
events
{
  use epoll;
  worker_connections 102400;
}


http
{
  include       mime.types;
  default_type  application/octet-stream;


  #charset  gb2312;


  server_names_hash_bucket_size 1280;
#  client_header_buffer_size 16k;
#  large_client_header_buffers 4 32k;
client_header_buffer_size 4k;
large_client_header_buffers 4 4k;
  client_max_body_size 80m;


  sendfile on;
  tcp_nopush     on;


  client_body_timeout  10;
  client_header_timeout 10;
  keepalive_timeout  30;
  send_timeout       15;


  #open_file_cache max=65535 inactive=20s;
  open_file_cache max=204800 inactive=20s;
  open_file_cache_valid 30s;
  open_file_cache_min_uses 1;


  tcp_nodelay on;


  fastcgi_connect_timeout 300;
  fastcgi_send_timeout 300;
  fastcgi_read_timeout 300;
  fastcgi_buffer_size 64k;
  fastcgi_buffers 4 64k;
  fastcgi_busy_buffers_size 128k;
  fastcgi_temp_file_write_size 128k;
  


  client_body_buffer_size  512k;
  proxy_connect_timeout    5;
  proxy_read_timeout       60;
  proxy_send_timeout       5;
  proxy_buffer_size        16k;
  proxy_buffers            4 64k;
  proxy_busy_buffers_size 128k;
  proxy_temp_file_write_size 128k;


  #vipshop_hostname on;  
 
  gzip on;
  gzip_min_length  1k;
  gzip_buffers     4 16k;
  gzip_http_version 1.0;
  gzip_comp_level 2;
  gzip_types       text/plain application/x-javascript text/css application/xml;
  gzip_vary on;


  #limit_zone  crawler  $binary_remote_addr  10m;
  proxy_temp_path   /dev/shm/temp;
  proxy_cache_path  /dev/shm/cache levels=2:2:2   keys_zone=cache_go:200m inactive=5d max_size=7g;




    #log_format main  '$remote_addr - $remote_user [$time_local] "$request" "$request_time" '
    #          '$status $body_bytes_sent "$http_referer" '
    #          '"$http_user_agent" $http_x_forwarded_for $host $hostname';
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer"  "$host" '
                      '"$http_user_agent" "$http_x_forwarded_for"  "$request_time" "$upstream_response_time"'; 
    # Monit Nginx
   # include      /apps/conf/nginx/vhosts/default.vipshop.com;
 server {
    listen 172.16.0.219:80 default;
    return 500;
    }
 
}

加载中
0
zigzagroad
zigzagroad
参考 http://m.oschina.net/question/1397765_167440
zigzagroad
zigzagroad
仅提供参考
bolbo
bolbo
有什么区别?
返回顶部
顶部