This is also something that I think we would likely find very helpful in
1.4.
On 11/20/2013 11:32 AM, Avatar wrote:
Ou, we've been waiting it so much. Really delightful thing.
Thanks.
On Mon, Nov 18, 2013 at 9:49 PM, James Hogarth <[email protected]> wrote:
Hi all,
We've been looking at improving the behaviour when nbproc > 1
We focused on making the unix control socket have deterministic rather than
almost random behaviour (depending on which process picks up the incoming
request).
There still remains larger issues with nbproc which may affect your decision
to use it (each process maintaining it's own session persistence, maxconns,
separated stats, etc) but this at least allows for some control of the
sessions when doing so.
The general idea was to make use of existing functionality to minimise code
additions or modifications and as such there is very little it touches that
could cause a problem in itself (indeed setting multiple stats socket lines
already created bindings to multiple control sockets but just to all
processes).
To control all processes a wrapper of some nature is still needed to iterate
through all the sockets to gather data or send commands to each one.
To make use of this functionality just have one stats socket line per
process defined in nbproc.
As an example:
global
nbproc 4
stats socket /var/run/haproxy.1.sock
stats socket /var/run/haproxy.2.sock
stats socket /var/run/haproxy.3.sock
stats socket /var/run/haproxy.4.sock
To stop sample-frontend only for maintenance on all processes:
for {1..4}
do
echo 'disable fontend sample-frontend' | socat /var/run/haproxy.1.sock
done
Kind regards,
James
___________
From e8c72a98b9b626f5c853f00f82dcfb1b6dec7764 Mon Sep 17 00:00:00 2001
From: James Hogarth <[email protected]>
Date: Mon, 18 Nov 2013 17:26:53 +0000
Subject: [PATCH] Add multiple sockets to stats process for the case nbproc >
1
---
doc/configuration.txt | 2 ++
src/cfgparse.c | 2 +-
src/haproxy.c | 19 +++++++++++++++++++
3 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/doc/configuration.txt b/doc/configuration.txt
index 0b4844b..0802739 100644
--- a/doc/configuration.txt
+++ b/doc/configuration.txt
@@ -632,6 +632,8 @@ stats socket [<address:port>|<path>] [param*]
All parameters supported by "bind" lines are supported, for instance to
restrict access to some users or their access rights. Please consult
section 5.1 for more information.
+
+ Multiple stats socket lines can be in global if nbproc is greater than 1
controlling each process.
stats timeout <timeout, in milliseconds>
The default timeout on the stats socket is set to 10 seconds. It is
possible
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 28507dd..5507d89 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -7144,7 +7144,7 @@ out_uri_auth_compat:
/* Check multi-process mode compatibility */
if (global.nbproc > 1) {
if (global.stats_fe && !global.stats_fe->bind_proc) {
- Warning("stats socket will not work as expected in multi-process mode
(nbproc > 1), you should force process binding using 'stats
bind-process'.\n");
+ Warning("stats socket will not work as expected in multi-process mode
(nbproc > 1), you should force process binding using 'stats bind-process' or
provide multiple stats sockets lines - one for each process.\n");
}
}
diff --git a/src/haproxy.c b/src/haproxy.c
index bc03a73..a15b81c 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -1563,6 +1563,25 @@ int main(int argc, char **argv)
px = px->next;
}
+ /* unbind unix control sockets leaving one on each process for
deterministic control */
+ {
+ int ListenCount = 1;
+ struct proxy * px = proxy;
+
+ while (px != NULL) {
+ if (strcmp(px->id , "GLOBAL") == 0) {
+ struct listener * l;
+ list_for_each_entry(l, &px->conf.listeners, by_fe) {
+ if(ListenCount != relative_pid && !(px->bind_proc)){
+ unbind_listener(l);
+ }
+ ListenCount++;
+ }
+ }
+ px = px->next;
+ }
+ }
+
if (proc == global.nbproc) {
if (global.mode & MODE_SYSTEMD) {
for (proc = 0; proc < global.nbproc; proc++)
--
1.8.4.2