Skip to content

Commit 4f3ec03

Browse files
committed
Add MAX_CONNECTIONS parameter.
1 parent 0eaa2b9 commit 4f3ec03

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ The proxy is configured via environment variables.
3131
* `CONCURRENCY` — The number of concurrent requests to allow through to
3232
gunicorn. It's recommended to set this equal to the number of gunicorn
3333
workers.
34+
* `MAX_CONNECTIONS` — The number of simultaneous connections HAProxy will
35+
accept. Defaults to 2000.
3436
* `SYSLOG_SERVER` — A syslog server to output logs to. Defaults to
3537
`localhost`.
3638
* `QUEUE_TIMEOUT` — How long requests will wait for a gunicorn worker before
@@ -53,12 +55,16 @@ The proxy will queue requests and return a 503 if they've queued too long.
5355
This load shedding allows the server to continue to serve some requests within
5456
a reasonable time during periods of excessive load.
5557

56-
## Healthchecks
57-
5858
Requests matching `HEALTHCHECK_PATH` skip the queue. This allows healthchecks
5959
to continue succeeding even when the proxy is load shedding, as long as
6060
gunicorn is still processing requests.
6161

62+
`MAX_CONNECTIONS` should be set to a number greater than `QUEUE_TIMEOUT`
63+
multiplied by the maximum number requests per second your application can
64+
serve. Otherwise HAProxy may start rejecting new connections before the queue
65+
fills up, negating the benefits of having one. `MAX_CONNECTIONS` defaults to
66+
2000, which should be great enough for most applications.
67+
6268
## Logging
6369

6470
Technically `SYSLOG_SERVER` is not required, as by default logs will be routed

run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ compression type text/html text/plain application/json
2121
cat <<EOF > /usr/local/etc/haproxy/haproxy.cfg
2222
2323
global
24-
maxconn 256
24+
maxconn ${MAX_CONNECTIONS:-2000}
2525
2626
defaults
2727
mode http

0 commit comments

Comments
 (0)