Question

Nginx Connection timed out while connecting to upstream on Docker-ized server during spike in requests

I’ve a dockerized server on DigitalOcean that have problems serving requests when spike traffic happens. This is the architecture:

Nginx-proxy <-> Nginx <-> PHP-FPM <-> MySQL

These a proxy wide parameters:

client_max_body_size 100M;
proxy_connect_timeout 3000;
proxy_send_timeout 3000;
proxy_read_timeout 3000;
send_timeout 3000;

And fastcgi inside locations file:

fastcgi_read_timeout 3000;

During spike logs: Proxy: correctly responds but with code 499/0 Nginx: upstream timed out (110: Connection timed out) while connecting to upstream)

(Reposting question originally asked by: @tech585b88c5b25f22dbb1db14 )

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hello, @aha

Can you also check the logs to see if the Nginx workers have been exceeded? You can see if the values for worker_connections and worker_processes is not set too low.

From my previous experience when I’m receiving the exact same error it’s related to the php-fpm. You can check the fpm pool is not exceeded as well. It’s really helpful to examine the fpm logs as well.

When the issue happens you can restart the fpm service to see if it will solve the issue. Then you will know that you must tweak the PHP-FPM pool configuration.

Let me know how it goes.