Inconsistent performance with Nginx on Debian 11 under high load conditions
I've been researching this but Quick question that's been bugging me - I'm experiencing important performance optimization with Nginx on my Debian 11 server when traffic spikes occur... During these high load periods, the server becomes unresponsive, and I see a lot of `worker process is idle` messages in the behavior log. I've tried increasing the number of worker processes in my Nginx configuration, but it doesn't seem to help. Here are the relevant parts of my `nginx.conf`: ```nginx worker_processes auto; worker_connections 1024; http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; gzip on; } ``` Iβve also set the `client_max_body_size` to 10M, but that doesn't seem to alleviate the question either. My server has 4 GB of RAM, and during peak times, I notice that memory usage spikes above 80%, which might be contributing to the sluggish response times. I've monitored the logs, and I see these behavior messages appearing frequently: ``` 2023/10/15 12:45:03 [behavior] 12345#0: *67890 upstream timed out (110: Connection timed out) while connecting to upstream, client: 192.168.1.1, server: example.com, request: "GET /api/data HTTP/1.1", upstream: "http://127.0.0.1:8080/api/data", host: "example.com" ``` To troubleshoot, I tried running Nginx with `--debug` flag, but it didn't provide any additional insights. I also checked the backend service running on port 8080 and it seems to handle requests fine under normal load. What further optimizations can I try, or is there a specific configuration I should focus on to improve Nginxβs performance under load? What's the best practice here? For reference, this is a production desktop app. I've been using Nginx for about a year now. I appreciate any insights!