]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MEDIUM] stats: add the ability to adjust the global maxconnrate
authorWilly Tarreau <w@1wt.eu>
Wed, 7 Sep 2011 14:13:44 +0000 (16:13 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 7 Sep 2011 20:47:42 +0000 (22:47 +0200)
Using "set rate-limit connections global <xxx>" on the CLI, we can now
adjust the per-process connection rate limiting (equal to global.maxconnrate).

doc/configuration.txt
src/dumpstats.c

index 62fc5e902ce0657c73325ef35075d7352c5fcaf2..ed09c32e05fec7b720cf6d89d59cbfd62801bd1f 100644 (file)
@@ -9580,6 +9580,12 @@ set maxconn global <maxconn>
   delayed until the threshold is reached. A value of zero restores the initial
   setting.
 
+set rate-limit connections global <value>
+  Change the process-wide connection rate limit, which is set by the global
+  'maxconnrate' setting. A value of zero disables the limitation. This limit
+  applies to all frontends and the change has an immediate effect. The value
+  is passed in number of connections per second.
+
 set timeout cli <delay>
   Change the CLI interface timeout for current connection. This can be useful
   during long debugging sessions where the user needs to constantly inspect
index 73d5ad649eaba8e57f61cdffd8a65be7fedb5d56..6d97f5da5a9cb17b113b991d095c609404071529 100644 (file)
@@ -85,6 +85,7 @@ static const char stats_sock_usage_msg[] =
        "  disable server : set a server in maintenance mode\n"
        "  enable server  : re-enable a server that was previously in maintenance mode\n"
        "  set maxconn    : change a maxconn setting\n"
+       "  set rate-limit : change a rate limiting value\n"
        "";
 
 static const char stats_permission_denied_msg[] =
@@ -1061,6 +1062,50 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line)
                                return 1;
                        }
                }
+               else if (strcmp(args[1], "rate-limit") == 0) {
+                       if (strcmp(args[2], "connections") == 0) {
+                               if (strcmp(args[3], "global") == 0) {
+                                       int v;
+
+                                       if (s->listener->perm.ux.level < ACCESS_LVL_ADMIN) {
+                                               si->applet.ctx.cli.msg = stats_permission_denied_msg;
+                                               si->applet.st0 = STAT_CLI_PRINT;
+                                               return 1;
+                                       }
+
+                                       if (!*args[4]) {
+                                               si->applet.ctx.cli.msg = "Expects an integer value.\n";
+                                               si->applet.st0 = STAT_CLI_PRINT;
+                                               return 1;
+                                       }
+
+                                       v = atoi(args[4]);
+                                       if (v < 0) {
+                                               si->applet.ctx.cli.msg = "Value out of range.\n";
+                                               si->applet.st0 = STAT_CLI_PRINT;
+                                               return 1;
+                                       }
+
+                                       global.cps_lim = v;
+
+                                       /* Dequeues all of the listeners waiting for a resource */
+                                       if (!LIST_ISEMPTY(&global_listener_queue))
+                                               dequeue_all_listeners(&global_listener_queue);
+
+                                       return 1;
+                               }
+                               else {
+                                       si->applet.ctx.cli.msg = "'set rate-limit connections' only supports 'global'.\n";
+                                       si->applet.st0 = STAT_CLI_PRINT;
+                                       return 1;
+                               }
+                       }
+                       else {
+                               si->applet.ctx.cli.msg = "'set rate-limit' only supports 'connections'.\n";
+                               si->applet.st0 = STAT_CLI_PRINT;
+                               return 1;
+                       }
+               }
                else { /* unknown "set" parameter */
                        return 0;
                }