Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Commit 8935341

Browse files
committed
Can configure haproxy nbproc and cpu map through env var
- adds the NBPROC property and binds haproxy threads to CPU if NBPROC > 1 - binds stats to latest proc/cpu core, if there is more than one proc http://www.cagataygurturk.com/using-haproxy-in-multicore-environments/ http://blog.onefellow.com/post/82478335338/haproxy-mapping-process-to-cpu-core-for-maximum Will be able to obtimise perfs with a following commits to specify cpu-map on each frontend.
1 parent 4405329 commit 8935341

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ ENV RSYSLOG_DESTINATION=127.0.0.1 \
2222
STATS_AUTH="stats:stats" \
2323
SSL_BIND_OPTIONS=no-sslv3 \
2424
SSL_BIND_CIPHERS="ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:DHE-DSS-AES128-SHA:DES-CBC3-SHA" \
25-
HEALTH_CHECK="check inter 2000 rise 2 fall 3"
25+
HEALTH_CHECK="check inter 2000 rise 2 fall 3" \
26+
NBPROC=1
2627

2728
EXPOSE 80 443 1936
2829
ENTRYPOINT ["/sbin/tini", "--"]

haproxy/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def parse_extra_frontend_settings(envvars):
6060
STATS_AUTH = os.getenv("STATS_AUTH", "stats:stats")
6161
STATS_PORT = os.getenv("STATS_PORT", "1936")
6262
TIMEOUT = os.getenv("TIMEOUT", "connect 5000, client 50000, server 50000")
63+
NBPROC = int(os.getenv("NBPROC", 1))
6364

6465
# global
6566
LINK_MODE = ""

haproxy/haproxycfg.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,12 @@ def _config_global_section():
195195
"daemon",
196196
"stats socket /var/run/haproxy.stats level admin"]
197197

198+
if NBPROC > 1:
199+
statements.append("nbproc %s" % NBPROC)
200+
statements.append("stats bind-process %s" % NBPROC)
201+
for x in range(1, NBPROC+1):
202+
statements.append("cpu-map %s %s" % (x, x-1))
203+
198204
statements.extend(ConfigHelper.config_ssl_bind_options(SSL_BIND_OPTIONS))
199205
statements.extend(ConfigHelper.config_ssl_bind_ciphers(SSL_BIND_CIPHERS))
200206
statements.extend(ConfigHelper.config_extra_settings(EXTRA_GLOBAL_SETTINGS))

0 commit comments

Comments
 (0)