Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.9k views
in Technique[技术] by (71.8m points)

对Nginx进行Webscoket压力测试

我们已经完成了一个Websocket服务,单机连接压力测试能到达5.5W的连接数,考虑到那台机子里面还有其他部署的服务,以上的连接数应该是正常的。
当使用Nginx来代理连接这个Websocket服务以后,我们使用jmeter压力测试只能到4.5,做负载均衡扩展websocket服务以后,连接更少只能到达3.3W左右。
请问,哪位有经验的大佬能帮我解决下这个问题?

这是nginx的主配置:

[root@gz_vm_Emergency_brodcast_nginx01_102 ~]# cat /usr/local/nginx/conf/nginx.conf
user  www www;
worker_processes 8;
#worker_cpu_affinity auto;
worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000;
error_log  /data/nginx/logs/error.log  crit;
pid        /usr/local/nginx/conf/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.

worker_rlimit_nofile 8192;
events
    {
        use epoll;
        worker_connections 8192;
        multi_accept on;
    }

http
    {
        include       mime.types;
        default_type  application/octet-stream;
        #general options
        server_names_hash_bucket_size 128;
        client_header_buffer_size 32k;
        large_client_header_buffers 4 128k;
        client_max_body_size 3000m;
        proxy_ignore_client_abort on;

        sendfile   on;
        tcp_nopush on;
        tcp_nodelay on;
        #keepalive_requests 10240;
        keepalive_timeout 300;
        max_ranges 1;

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

        gzip off;
        gzip_min_length  1k;
        gzip_buffers     4 16k;
        gzip_http_version 1.1;
        gzip_comp_level 2;
        gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
        gzip_vary on;
        gzip_proxied   expired no-cache no-store private auth;
        gzip_disable   "MSIE [1-6].";

        server_tokens off;
        #log format
        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for" "$upstream_addr"';
        access_log  /data/nginx/logs/access.log  main;

#-------------------
        include /usr/local/nginx/conf.d/*.conf;
}

这是负载均衡的配置:

[root@gz_vm_Emergency_brodcast_nginx01_102 ~]# cat /usr/local/nginx/conf.d/web.conf 
upstream lpkj_emergency {
          server ip:11170 max_fails=2 fail_timeout=30s;
          server ip:11170 max_fails=2 fail_timeout=30s;
          #server ip:11170 max_fails=2 fail_timeout=30s;
          #server ip:11170 max_fails=2 fail_timeout=30s;
          keepalive 300;
}

#--------------------------------------------------

server
     {
        listen 11170;
        server_name  ip;

        #proxy_buffering on;
        #proxy_buffer_size 8k;
        #proxy_buffers 8 4k;
        #proxy_busy_buffer_size 64k;


         location / {
            proxy_set_header Host $host:11170;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_pass http://lpkj_emergency;
            proxy_http_version 1.1;
#            proxy_read_timeout   3600s;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
#            proxy_connect_timeout 1200s;
#            proxy_read_timeout 3600s;
#            proxy_send_timeout 3600s;
            }

        location /status {
        stub_status on;
        auth_basic "nginxstatus";
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

       #access_log  /data/nginx/logs/proxy_access.log  main;
       #access_log  /data/nginx/logs/proxy_access.log  main buffer=1024k;
       access_log  off;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...