Skip to content

With high concurrency and frequent dns changes, the work process of nginx is deadlocked #40

Open
@Liyij

Description

@Liyij

Hello, I have added stream module support to your nginx-upstream-dynamic-servers module. During stress testing, I found that nginx is configured with 16 worker processes. When there are 200,000 QPS requests per second and the DNS frequently changes, one of the worker processes in nginx experiences a CPU usage of 100%, leading to a deadlock situation. Debugging with gdb reveals a deadlock condition (ngx_rwlock_wlock). could you take a look at this issue and give me some advice?

Here is my configuration:
stream {
tcp_nodelay on;
open_log_file_cache off;
resolver 127.0.0.1 valid=60s ipv6=off;
proxy_next_upstream_tries 2;

upstream backendlz0980 {
   server obsxxx.xxx.xxx:80 fail_timeout=5s max_fails=5 resolve;

}
server {
    access_log /var/log/nginx/static-website.access_x.log main;
    error_log /var/log/nginx/static-website.error_x.log;

    listen 168.xxx.xxx reuseport;

    proxy_pass backendlz0980;
    proxy_connect_timeout 2s;
    proxy_timeout 10s;
    tcp_nodelay on;
    #proxy_protocol on;
}

}

This is the function stack of the process that has the issue:

#0 0x000055d5b9cf2b1a in ngx_rwlock_wlock ()
#1 0x000055d5b9ddb5d3 in ngx_stream_upstream_free_round_robin_peer ()
#2 0x000055d5b9dd65b7 in ngx_stream_proxy_finalize ()
#3 0x000055d5b9d0caa1 in ngx_epoll_process_events ()
#4 0x000055d5b9d00c86 in ngx_process_events_and_timers ()
#5 0x000055d5b9d0a285 in ngx_worker_process_cycle ()
#6 0x000055d5b9d08aef in ngx_spawn_process ()
#7 0x000055d5b9d0a590 in ngx_start_worker_processes ()
#8 0x000055d5b9d0b2d2 in ngx_master_process_cycle ()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions