Places to update request timeout in Aws/Django/Gunicorn

Jaleel Nazir
2 min readJan 28, 2023

--

Updating the timeout values in a Django application can be a bit tricky, as it involves making changes to multiple components — AWS Elastic Load Balancer (ELB), Nginx, and Supervisor (Gunicorn config). In this article, we will go through the steps required to update the timeout values in each of these components.

  1. AWS Elastic Load Balancer (ELB)

The first step is to update the idle timeout value on the AWS ELB. To do this, navigate to the Attributes section of the ELB and update the idle timeout value to your desired value. This value controls the amount of time that the ELB will wait for a response from the backend before marking the connection as idle.

  1. Nginx

The next step is to update the timeout values in the Nginx config. To do this, add the following values to the location/server block in the Nginx config file:

proxy_connect_timeout 900;

proxy_send_timeout 900;

proxy_read_timeout 900;

send_timeout 900;

  • proxy_connect_timeout sets the timeout for establishing a connection to the proxied server.
  • proxy_send_timeout sets the timeout for transmitting a request to the proxied server.
  • proxy_read_timeout sets the timeout for receiving a response from the proxied server.
  • send_timeout sets the timeout for transmitting a response to the client.

These values control the amount of time that Nginx will wait for a response from the backend before timing out the connection.

  1. Supervisor and Gunicorn

Finally, we need to update the timeout values in the Gunicorn command that is used to start the application. This command can be found in the supervisor conf file or in the Python config file that is mentioned in the supervisor conf file.

To update the timeout value, add the following flag to the Gunicorn command:

— timeout 900

This flag controls the amount of time that Gunicorn will wait for a response from the backend before timing out the connection.

In conclusion, updating the timeout values in a Django application involves making changes to multiple components — AWS ELB, Nginx, and Supervisor (Gunicorn config). By following the steps outlined in this article, you should be able to successfully update the timeout values in your application and ensure that it is running smoothly.

P.S:

As a developer, I am constantly on the lookout for tools that can improve my workflow and productivity.
However, the process of searching for these tools can be tedious and overwhelming, with many websites cluttered with ads and pop-ups.

That’s why I am committed to creating Fictos.com, a central hub for developers to easily find and access the tools they need, with over 1000 tools by the end of 2023.

Your sponsorship will greatly aid in the development and success of this project, and I appreciate your support.

--

--