Skip to content

Commit 35ca7a7

Browse files
author
Arne-Christian Blystad
committed
fix(router): Unify timeout values
The router was having different timeout values for keepalive_timeout and for proxy timeouts. This can cause issues with front facing load balancers in front of deis-router (like Amazon ELB), and could be the cause of issue #3448 Timeout values should be greater than the timeout value of the front facing load balancer. Ref: > The keepalive timeout value on your backend server must be higher than that > of your ELB connection timeout. If it is lower, the ELB will re-use the idle > connection when your server has already dropped the connection, resulting in > the client being served up a blank response. http://engineering.chartbeat.com/2014/02/12/part-2-lessons-learned-tuning-tcp-and-nginx-in-ec2/ > The ELB timeout should be set to less then the backend server idle timeout. https://forums.aws.amazon.com/thread.jspa?threadID=104688
1 parent a4bf040 commit 35ca7a7

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

docs/customizing_deis/router_settings.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ setting description
3939
/deis/domains/* domain configuration for applications (set by controller)
4040
/deis/router/affinityArg for requests with the indicated query string variable, hash its contents to perform session affinity (default: undefined)
4141
/deis/router/bodySize nginx body size setting (default: 1m)
42+
/deis/router/defaultTimeout default timeout value in seconds. Should be greater then the frontfacing load balancers timeout value (default: 1300)
4243
/deis/router/builder/timeout/connect proxy_connect_timeout for deis-builder (default: 10000). Unit in miliseconds
4344
/deis/router/builder/timeout/read proxy_read_timeout for deis-builder (default: 1200000). Unit in miliseconds
4445
/deis/router/builder/timeout/send proxy_send_timeout for deis-builder (default: 1200000). Unit in miliseconds

router/image/templates/nginx.conf

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ http {
1515
sendfile on;
1616
tcp_nopush on;
1717
tcp_nodelay on;
18-
keepalive_timeout 65;
18+
19+
# The Timeout value must be greater than the front facing load balancers timeout value.
20+
# Default is the deis recommended timeout value for ELB - 1200 seconds + 100s extra.
21+
{{ $defaultTimeout := or (.deis_router_defaultTimeout) "1300" }}
22+
keepalive_timeout {{ $defaultTimeout }};
1923

2024
types_hash_max_size 2048;
2125
server_names_hash_max_size {{ or (.deis_router_serverNameHashMaxSize) "512" }};
@@ -125,8 +129,8 @@ http {
125129
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
126130
proxy_redirect off;
127131
proxy_connect_timeout 10s;
128-
proxy_send_timeout 1200s;
129-
proxy_read_timeout 1200s;
132+
proxy_send_timeout {{ $defaultTimeout }}s;
133+
proxy_read_timeout {{ $defaultTimeout }}s;
130134

131135
proxy_pass http://deis-store-gateway;
132136
}
@@ -194,8 +198,8 @@ http {
194198
proxy_set_header X-Forwarded-Ssl $access_ssl;
195199
proxy_redirect off;
196200
proxy_connect_timeout 30s;
197-
proxy_send_timeout 1200s;
198-
proxy_read_timeout 1200s;
201+
proxy_send_timeout {{ $defaultTimeout }}s;
202+
proxy_read_timeout {{ $defaultTimeout }}s;
199203
proxy_http_version 1.1;
200204
proxy_set_header Upgrade $http_upgrade;
201205
proxy_set_header Connection $connection_upgrade;
@@ -244,8 +248,8 @@ http {
244248
proxy_set_header X-Forwarded-Ssl $access_ssl;
245249
proxy_redirect off;
246250
proxy_connect_timeout 30s;
247-
proxy_send_timeout 1200s;
248-
proxy_read_timeout 1200s;
251+
proxy_send_timeout {{ $defaultTimeout }}s;
252+
proxy_read_timeout {{ $defaultTimeout }}s;
249253
proxy_http_version 1.1;
250254
proxy_set_header Upgrade $http_upgrade;
251255
proxy_set_header Connection $connection_upgrade;

0 commit comments

Comments
 (0)