Skip to content

Commit 803b7cf

Browse files
committed
connection pooling
1 parent 4b460f7 commit 803b7cf

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ ENV STATIC_LOCATIONS=
1616
ENV NO_ACCESS_LOGS=0
1717
ENV LOG_ONLY_5XX=0
1818
ENV WORKER_CONNECTIONS=1024
19+
ENV KEEPALIVE_CONNECTIONS=32
20+
ENV KEEPALIVE_REQUESTS=1000
1921

2022
EXPOSE 80
2123
STOPSIGNAL SIGQUIT

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ Pair nginx-proxy with your favorite upstream server (wsgi, uwsgi, asgi, et al.)
2323
| `SILENT` | Silence entrypoint output | No | | |
2424
| `STATIC_LOCATIONS` | Static asset mappings | No | | |
2525
| `PROXY_UWSGI` | Whether to use native uwsgi support | No | 0 | 1 |
26-
| `KEEPALIVE_TIMEOUT` | What value to set HTTP keepalive (This should be higher than your ELB's timeout) | Yes | 65 | |
26+
| `KEEPALIVE_TIMEOUT` | HTTP keepalive timeout and upstream connection timeout | Yes | 65 | |
27+
| `KEEPALIVE_CONNECTIONS` | Number of idle connections to keep alive to upstream | No | 32 | 64 |
28+
| `KEEPALIVE_REQUESTS` | Number of requests per upstream connection before recycling | No | 1000 | 2000 |
2729
| `HEALTHCHECK_PATH` | nginx-proxy disables healthcheck path access logs, you can configure the path here | Yes | /lb-status/ | |
2830
| `NO_ACCESS_LOGS` | disable access logs completely | No | 0 | 1 |
2931
| `LOG_ONLY_5XX` | only log 5XX HTTP status access events | No | 0 | 1 |

src/etc/nginx/conf.d/default.conf.template

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ server {
1010

1111
upstream app {
1212
server {{ .Env.UPSTREAM_SERVER }};
13+
keepalive {{ .Env.KEEPALIVE_CONNECTIONS }};
14+
keepalive_requests {{ .Env.KEEPALIVE_REQUESTS }};
15+
keepalive_timeout {{ .Env.KEEPALIVE_TIMEOUT }}s;
1316
}
1417

1518
server {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
uwsgi_pass app;
22
uwsgi_param HTTP_X_REQUEST_ID $request_id;
33
uwsgi_param HTTP_HOST $host;
4+
uwsgi_param CONNECTION ""; # Clear Connection header for keepalive
45
include uwsgi_params;
56
uwsgi_read_timeout {{ .Env.WSGI_TIMEOUT }};
67
uwsgi_send_timeout {{ .Env.WSGI_TIMEOUT }};

0 commit comments

Comments
 (0)