]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] compute the max of sessions/s on fe/be/srv
authorWilly Tarreau <w@1wt.eu>
Sun, 10 May 2009 16:52:49 +0000 (18:52 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 10 May 2009 16:52:49 +0000 (18:52 +0200)
Some users want to keep the max sessions/s seen on servers, frontends
and backends for capacity planning. It's easy to grab it while the
session count is updated, so let's keep it.

include/proto/proxy.h
include/proto/server.h
include/types/proxy.h
include/types/server.h
src/cfgparse.c
src/client.c
src/proxy.c

index e56de12319a368fc031b3642fbd3435133b12f08..adb16cef4db5af7776cc0ab612e93d47c947cd4b 100644 (file)
@@ -69,6 +69,8 @@ static void inline proxy_inc_fe_ctr(struct proxy *fe)
 {
        fe->cum_feconn++;
        update_freq_ctr(&fe->fe_sess_per_sec, 1);
+       if (fe->fe_sess_per_sec.curr_ctr > fe->fe_sps_max)
+               fe->fe_sps_max = fe->fe_sess_per_sec.curr_ctr;
 }
 
 /* increase the number of cumulated connections on the designated backend */
@@ -76,6 +78,8 @@ static void inline proxy_inc_be_ctr(struct proxy *be)
 {
        be->cum_beconn++;
        update_freq_ctr(&be->be_sess_per_sec, 1);
+       if (be->be_sess_per_sec.curr_ctr > be->be_sps_max)
+               be->be_sps_max = be->be_sess_per_sec.curr_ctr;
 }
 
 #endif /* _PROTO_PROXY_H */
index e05a4acec52fafd63566b3201778471fe0e5464e..7479c2e69027c917973d5bfa3f0493d247c8c218 100644 (file)
@@ -40,6 +40,8 @@ static void inline srv_inc_sess_ctr(struct server *s)
 {
        s->cum_sess++;
        update_freq_ctr(&s->sess_per_sec, 1);
+       if (s->sess_per_sec.curr_ctr > s->sps_max)
+               s->sps_max = s->sess_per_sec.curr_ctr;
 }
 
 #endif /* _PROTO_SERVER_H */
index 7ef5fc89a26ab036dddecc25b08c7caa43a3d61c..9e49bd83052d269ed809f33ad33d810b150394c8 100644 (file)
@@ -230,11 +230,13 @@ struct proxy {
        unsigned int feconn, feconn_max;        /* # of active frontend sessions */
        unsigned int beconn, beconn_max;        /* # of active backend sessions */
        struct freq_ctr fe_sess_per_sec;        /* sessions per second on the frontend */
+       unsigned int fe_sps_max;                /* maximum of new sessions per second seen on the frontend */
        struct freq_ctr be_sess_per_sec;        /* sessions per second on the backend */
+       unsigned int be_sps_max;                /* maximum of new sessions per second seen on the backend */
        long long cum_feconn, cum_beconn;       /* cumulated number of processed sessions */
        long long cum_lbconn;                   /* cumulated number of sessions processed by load balancing */
        unsigned int maxconn;                   /* max # of active sessions on the frontend */
-       unsigned int fe_maxsps;                 /* max # of new sessions per second on the frontend */
+       unsigned int fe_sps_lim;                /* limit on new sessions per second on the frontend */
        unsigned int fullconn;                  /* #conns on backend above which servers are used at full load */
        struct in_addr except_net, except_mask; /* don't x-forward-for for this address. FIXME: should support IPv6 */
        struct in_addr except_to;               /* don't x-original-to for this address. */
index a52a9d858e3ac79a26219b3fd7902abb1933a9aa..7c7a54e9fdb7d2051a8291fb8f11bd6884e0fbf1 100644 (file)
@@ -124,6 +124,7 @@ struct server {
        long long retries, redispatches;                /* retried and redispatched connections */
        long long failed_secu;                  /* blocked responses because of security concerns */
        struct freq_ctr sess_per_sec;           /* sessions per second on this server */
+       unsigned int sps_max;                   /* maximum of new sessions per second seen on this server */
        long long cum_sess;                     /* cumulated number of sessions really sent to this server */
        long long cum_lbconn;                   /* cumulated number of sessions directed by load balancing */
 
index e3c8b62958c7c4cf1c164e1463552a644c64d569..bfcccf2648e8b5eee59a99fdc725abe85bc51b9e 100644 (file)
@@ -787,7 +787,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int inv)
                if (curproxy->cap & PR_CAP_FE) {
                        curproxy->maxconn = defproxy.maxconn;
                        curproxy->backlog = defproxy.backlog;
-                       curproxy->fe_maxsps = defproxy.fe_maxsps;
+                       curproxy->fe_sps_lim = defproxy.fe_sps_lim;
 
                        /* initialize error relocations */
                        for (rc = 0; rc < HTTP_ERR_SIZE; rc++) {
index eb61da5eccd187ef99bf61b68a725a5be9234e08..3e156eb786c73aad5ffe82a8f1ba1a4b28e55058 100644 (file)
@@ -70,8 +70,8 @@ int event_accept(int fd) {
        int cfd;
        int max_accept = global.tune.maxaccept;
 
-       if (p->fe_maxsps) {
-               int max = freq_ctr_remain(&p->fe_sess_per_sec, p->fe_maxsps, 0);
+       if (p->fe_sps_lim) {
+               int max = freq_ctr_remain(&p->fe_sess_per_sec, p->fe_sps_lim, 0);
                if (max_accept > max)
                        max_accept = max;
        }
index a64bd0c88bff09c614815000a2ca4f64c78e0c9f..b3b33d4829c79dd8fed5edee50d1232d8981e1c9 100644 (file)
@@ -195,8 +195,8 @@ static int proxy_parse_rate_limit(char **args, int section, struct proxy *proxy,
        name = args[0];
        if (!strcmp(args[0], "sessions")) {
                name = "sessions";
-               tv = &proxy->fe_maxsps;
-               td = &defpx->fe_maxsps;
+               tv = &proxy->fe_sps_lim;
+               td = &defpx->fe_sps_lim;
                cap = PR_CAP_FE;
        } else {
                snprintf(err, errlen,
@@ -414,8 +414,8 @@ void maintain_proxies(int *next)
                        if (p->feconn >= p->maxconn)
                                goto do_block;
 
-                       if (p->fe_maxsps &&
-                           (wait = next_event_delay(&p->fe_sess_per_sec, p->fe_maxsps, 0))) {
+                       if (p->fe_sps_lim &&
+                           (wait = next_event_delay(&p->fe_sess_per_sec, p->fe_sps_lim, 0))) {
                                /* we're blocking because a limit was reached on the number of
                                 * requests/s on the frontend. We want to re-check ASAP, which
                                 * means in 1 ms before estimated expiration date, because the