]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: config: make the tasks "nice" value configurable on "bind" lines.
authorWilly Tarreau <w@1wt.eu>
Thu, 6 Sep 2012 12:26:36 +0000 (14:26 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 6 Sep 2012 12:28:58 +0000 (14:28 +0200)
This is very convenient to reduce SSL processing priority compared to
other traffic. This applies to CPU usage only, but has a direct impact
on latency under congestion.

doc/configuration.txt
src/cfgparse.c

index e11b140f35de3a8ac8c2a0a5787df9b79008fc77..5501444668d9a69e84f6f8ca06e89891ac22ccc1 100644 (file)
@@ -1483,6 +1483,7 @@ bind [<address>]:<port_range> [, ...] interface <interface>
 bind [<address>]:<port_range> [, ...] mss <maxseg>
 bind [<address>]:<port_range> [, ...] backlog <backlog>
 bind [<address>]:<port_range> [, ...] maxconn <maxconn>
+bind [<address>]:<port_range> [, ...] nice <nice>
 bind [<address>]:<port_range> [, ...] transparent
 bind [<address>]:<port_range> [, ...] id <id>
 bind [<address>]:<port_range> [, ...] name <name>
@@ -1572,6 +1573,17 @@ bind /<path> [, ...] [ group <user> | gid <gid> ]
                   assigned if unset. Can only be used when defining only a
                   single socket.
 
+    <nice>        sets the 'niceness' of connections initiated from the socket.
+                  Value must be in the range -1024..1024, and default is zero.
+                  Positive values means that such connections are more friendly
+                  to others and easily offer their place in the scheduler. On
+                  the opposite, negative values mean that connections want to
+                  run with a higher priority. The difference only happens under
+                  high loads when the system is close to saturation. Negative
+                  values are appropriate for low-latency or admin services, and
+                  high values are generally recommended for CPU intensive tasks
+                  such as SSL processing which are less sensible to latency.
+
     <name>        is an optional name provided for stats
 
     <mode>        is the octal mode used to define access permissions on the
index 925013a35eb8d2016c838e32cf3aaafbefd718d2..00531e594fcecfe9f78928aa901f48310597d913 100644 (file)
@@ -1875,6 +1875,32 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
                                continue;
                        }
 
+                       if (!strcmp(args[cur_arg], "nice")) {
+                               struct listener *l;
+                               int val;
+
+                               if (!*args[cur_arg + 1]) {
+                                       Alert("parsing [%s:%d] : '%s' : missing nice value.\n",
+                                             file, linenum, args[0]);
+                                       err_code |= ERR_ALERT | ERR_FATAL;
+                                       goto out;
+                               }
+
+                               val = atol(args[cur_arg + 1]);
+                               if (val < -1024 || val > 1024) {
+                                       Alert("parsing [%s:%d] : '%s' : invalid nice value %d, allowed range is -1024..1024.\n",
+                                             file, linenum, args[0], val);
+                                       err_code |= ERR_ALERT | ERR_FATAL;
+                                       goto out;
+                               }
+
+                               for (l = curproxy->listen; l != last_listen; l = l->next)
+                                       l->nice = val;
+
+                               cur_arg += 2;
+                               continue;
+                       }
+
                        if (!strcmp(args[cur_arg], "ssl")) { /* use ssl certificate */
 #ifdef USE_OPENSSL
                                struct listener *l;