Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increase buffer timeout size on nginx

I have a nodejs program that connects to cloudstack apis. Creating a Virtual Machine on cloudstack takes almost 20 secs.

The program works fine on my local nodejs installation and also on apigee cloud. However when I deploy the same on customer's OPDK, Nginx returns a 502 - Bad gateway. This link http://www.nginxtips.com/502-bad-gateway-using-nginx/ recommends increasing the buffer and timeout sizes in nginx.conf

http {
...
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
...
}

What is the recommended ideal value? What is it on Apigee cloud?

Regards, Girish

like image 398
Girish BR Avatar asked Dec 20 '22 17:12

Girish BR


1 Answers

You may need to look at the proxy timeout configs in nginx if using nginx as a proxy:

http://www.nginxtips.com/504-gateway-time-out-using-nginx/
http://wiki.nginx.org/HttpProxyModule

 proxy_connect_timeout       60;
 proxy_read_timeout          120;

Apigee timeout defaults:

Connect timeout - 60s - connect.timeout.millis
Read timeout - 120s - io.timeout.millis

FYI Apigee timeouts are also configurable (in milliseconds) within the TargetEndpoint connection:

<HTTPTargetConnection>
    <Properties>
        <Property name="connect.timeout.millis">5000</Property>
        <Property name="io.timeout.millis">5000</Property>
    </Properties>
    <URL>http://www.google.com</URL>
</HTTPTargetConnection>

Depending on how long the server takes to respond can determine your ideal timeout configurations. In this case, a read timeout of 45-60s might be ideal to provide some buffer in case cloudstack slows down more.

like image 95
Michael Russo Avatar answered Dec 28 '22 06:12

Michael Russo