client => nginx_proxy => upstream_server(nginx+php)request php curl interface nginx proxy nginx.conf

user  www;
worker_processes  40;

error_log  /data/logs/nginx/error.log   error;
pid        logs/nginx.pid;

worker_rlimit_nofile 102400;

events {
    worker_connections  102400;

http {
    log_format  sun  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for" $request_time $upstream_response_time $upstream_addr $upstream_status $upstream_cache_status';

    access_log  /data/logs/nginx/access.log sun;

    include       mime.types;
    include       conf.d/*.conf;
    default_type  application/octet-stream;
    lua_package_path "/usr/local/webserver/openresty/lualib/lua-resty-jwt/lib/?.lua;/usr/local/webserver/openresty/nginx/conf/lua.d/mall/?.lua;;";

    server_tokens off;
    sendfile        on;
    tcp_nopush      on;
    tcp_nodelay     on;
    keepalive_timeout  60;

    server_names_hash_bucket_size 256;
    client_header_buffer_size 32k;
    large_client_header_buffers 4 32k;
    client_max_body_size 300m;

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

    fastcgi_connect_timeout 300;
    fastcgi_send_timeout    300;
    fastcgi_read_timeout 300;
    fastcgi_buffer_size 128k;
    fastcgi_buffers 4 128k;
    fastcgi_busy_buffers_size   128k;
    fastcgi_temp_file_write_size 128k;
#    fastcgi_max_temp_file_size   0;
    fastcgi_intercept_errors on;

    fastcgi_cache_key "$scheme$request_method$host$request_uri";
    fastcgi_cache_use_stale error timeout invalid_header http_500;
    fastcgi_ignore_headers Cache-Control Expires Set-Cookie;

    fastcgi_temp_path fastcgi_temp;
    fastcgi_cache_path fastcgi_cache levels=1:2 keys_zone=fastcgi_cache_one:100m inactive=10m max_size=5g;

    proxy_connect_timeout   60s;
    proxy_read_timeout      60s;
    proxy_send_timeout      60s;
    proxy_buffer_size       16k;
    proxy_buffers           4 64k;
    proxy_busy_buffers_size 128k;
    proxy_temp_file_write_size  128k;

    proxy_temp_path  /tmpfs_cache/proxy_temp 1 2;
    proxy_cache_path /tmpfs_cache/proxy_cache levels=1:2 keys_zone=cache_one:100m max_size=5g inactive=60m use_temp_path=off;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    #proxy_pass http://backend_server;
    proxy_http_version 1.1;
    proxy_set_header Connection "";
    proxy_set_header Accept-Encoding "";
    proxy_cache_revalidate on;

    open_file_cache max=102400 inactive=30s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 1;
    open_file_cache_errors on;
    underscores_in_headers on;
    proxy_hide_header Vary;
    proxy_ignore_headers Set-Cookie Cache-Control Expires Vary;

    split_clients "$remote_addr$remote_port" $split_ip {

nginx proxy auth.open.sundayhk.com

upstream oauth.open.cluster {
    check interval=1000 rise=1 fall=2 timeout=1000;
    #hash $remote_addr consistent;

    location / {
        include other/cors.conf;
        proxy_bind $split_ip;
        proxy_pass http://oauth.open.cluster/;
        proxy_set_header Host oauth.open.sundayhk.com;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_redirect off;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        #proxy_hide_header Set-Cookie; 

Turn on "hash $ remote_addr" to bind to one of the servers ,concurrent 830 / s. Server cpu pressure is 50%

Turn off hash "#hash $ remote_addr consistent;" and "#ip_hash;", concurrent Also 830 / s, concurrent pressure is assigned to each server, each server CPU pressure is 13-15%; can not exceed 2000 concurrent I tried using 3 pressure measuring machines is also 830 / s

nginx_proxy and upstream_server Hardware Configuration: DELL R620 CPU E5-2680V2 x2 128G ssd s3710 400g

pic1 pic2 pic3 pic4 pic5

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.