504 Gateway Time-out

Source: Internet
Author: User

Modify Nginx.conf:


Fastcgi_send_timeout 300;

Fastcgi_read_timeout 300;

Fastcgi_buffer_size 128k;

Fastcgi_buffers 8 128k;

Fastcgi_busy_buffers_size 128k;

Fastcgi_temp_file_write_size 256k;

After the restart nginx,504 gateway timeout is mitigated, no similar situation occurs.

  1. Situation one: Due to nginx default fastcgi process response buffer too small caused

    This situation causes the FASTCGI process to be suspended, and if the FASTCGI service is not well-handled, it may prompt "504 Gateway time-out" error.

  2. 2

    Situation One solution:

    The default fastcgi process response buffer is 8K, we can set a larger, in nginx.conf, join: Fastcgi_buffers 8 128k

    This indicates that the fastcgi buffer is set to a size of 8 128k in space.

  3. 3

    Situation one solution (improvement):

    After the above method is modified, if the problem still occurs, we can continue to modify the Nginx timeout parameter, the parameter is a bit larger, such as set to 60 seconds:

    Send_timeout 60;

    After the adjustment of these two parameters, the results did not prompt "504 Gateway time-out" error, indicating that the effect is quite good, the problem is basically solved.

  4. 4

    Scenario Two: Configuration issues for the PHP environment

    Here we need to make configuration changes to PHP-FPM and Nginx. Because of this scenario, the "504 Gateway time-out" error message appears.

  5. 5

    Situation two solutions (PHP-FPM configuration Modification):

    Change the Max_children from the previous 10 to 30, so the operation is to ensure that there is sufficient php-cgi process can be used.

    Change the request_terminate_timeout from the previous 0 seconds to 60 seconds, which increases the time-out of the PHP-CGI process processing script to 60 seconds, preventing the process from being suspended to improve utilization efficiency.

  6. 6

    Scenario Two solutions (Nginx configuration Modification):

    In order to reduce the number of FASTCGI requests, as far as possible to maintain buffers unchanged, we want to change the Nginx several configuration items, as follows:

    Change the fastcgi_buffers from 4 to 64k to 2 256k;

    Change the fastcgi_buffer_size from 64k to 128k;

    Change the fastcgi_busy_buffers_size from 128k to 256k;

    Change the fastcgi_temp_file_write_size from 128k to 256k.

  7. 7

    When the two solutions are modified, we need to reload the PHP-FPM and Nginx configurations before testing. Then did not find "504 Gateway time-out" error, the effect is also good!

504 Gateway Time-out

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.