mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 15:47:01 +02:00
MINOR: counters: move freq-ctr from proxy/server into counters struct
Move freq-ctr defined in proxy or server structures into their dedicated fe_counters/be_counters struct. Functionnaly no change here. This commit will allow to convert rate stats column to generic one, which is mandatory to manipulate them in the stats-file.
This commit is contained in:
parent
4e9e841878
commit
639e73f8f2
@ -23,6 +23,8 @@
|
|||||||
#ifndef _HAPROXY_COUNTERS_T_H
|
#ifndef _HAPROXY_COUNTERS_T_H
|
||||||
#define _HAPROXY_COUNTERS_T_H
|
#define _HAPROXY_COUNTERS_T_H
|
||||||
|
|
||||||
|
#include <haproxy/freq_ctr-t.h>
|
||||||
|
|
||||||
/* counters used by listeners and frontends */
|
/* counters used by listeners and frontends */
|
||||||
struct fe_counters {
|
struct fe_counters {
|
||||||
unsigned int conn_max; /* max # of active sessions */
|
unsigned int conn_max; /* max # of active sessions */
|
||||||
@ -63,6 +65,10 @@ struct fe_counters {
|
|||||||
long long cache_hits; /* cache hits */
|
long long cache_hits; /* cache hits */
|
||||||
} http;
|
} http;
|
||||||
} p; /* protocol-specific stats */
|
} p; /* protocol-specific stats */
|
||||||
|
|
||||||
|
struct freq_ctr sess_per_sec; /* sessions per second on this server */
|
||||||
|
struct freq_ctr req_per_sec; /* HTTP requests per second on the frontend */
|
||||||
|
struct freq_ctr conn_per_sec; /* received connections per second on the frontend */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* counters used by servers and backends */
|
/* counters used by servers and backends */
|
||||||
@ -115,6 +121,8 @@ struct be_counters {
|
|||||||
long long cache_hits; /* cache hits */
|
long long cache_hits; /* cache hits */
|
||||||
} http;
|
} http;
|
||||||
} p; /* protocol-specific stats */
|
} p; /* protocol-specific stats */
|
||||||
|
|
||||||
|
struct freq_ctr sess_per_sec; /* sessions per second on this server */
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _HAPROXY_COUNTERS_T_H */
|
#endif /* _HAPROXY_COUNTERS_T_H */
|
||||||
|
@ -34,7 +34,6 @@
|
|||||||
#include <haproxy/backend-t.h>
|
#include <haproxy/backend-t.h>
|
||||||
#include <haproxy/compression-t.h>
|
#include <haproxy/compression-t.h>
|
||||||
#include <haproxy/counters-t.h>
|
#include <haproxy/counters-t.h>
|
||||||
#include <haproxy/freq_ctr-t.h>
|
|
||||||
#include <haproxy/guid-t.h>
|
#include <haproxy/guid-t.h>
|
||||||
#include <haproxy/obj_type-t.h>
|
#include <haproxy/obj_type-t.h>
|
||||||
#include <haproxy/queue-t.h>
|
#include <haproxy/queue-t.h>
|
||||||
@ -354,10 +353,6 @@ struct proxy {
|
|||||||
struct queue queue; /* queued requests (pendconns) */
|
struct queue queue; /* queued requests (pendconns) */
|
||||||
int totpend; /* total number of pending connections on this instance (for stats) */
|
int totpend; /* total number of pending connections on this instance (for stats) */
|
||||||
unsigned int feconn, beconn; /* # of active frontend and backends streams */
|
unsigned int feconn, beconn; /* # of active frontend and backends streams */
|
||||||
struct freq_ctr fe_req_per_sec; /* HTTP requests per second on the frontend */
|
|
||||||
struct freq_ctr fe_conn_per_sec; /* received connections per second on the frontend */
|
|
||||||
struct freq_ctr fe_sess_per_sec; /* accepted sessions per second on the frontend (after tcp rules) */
|
|
||||||
struct freq_ctr be_sess_per_sec; /* sessions per second on the backend */
|
|
||||||
unsigned int fe_sps_lim; /* limit on 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 */
|
unsigned int fullconn; /* #conns on backend above which servers are used at full load */
|
||||||
unsigned int tot_fe_maxconn; /* #maxconn of frontends linked to that backend, it is used to compute fullconn */
|
unsigned int tot_fe_maxconn; /* #maxconn of frontends linked to that backend, it is used to compute fullconn */
|
||||||
|
@ -134,7 +134,7 @@ static inline void proxy_inc_fe_conn_ctr(struct listener *l, struct proxy *fe)
|
|||||||
if (l && l->counters)
|
if (l && l->counters)
|
||||||
_HA_ATOMIC_INC(&l->counters->cum_conn);
|
_HA_ATOMIC_INC(&l->counters->cum_conn);
|
||||||
HA_ATOMIC_UPDATE_MAX(&fe->fe_counters.cps_max,
|
HA_ATOMIC_UPDATE_MAX(&fe->fe_counters.cps_max,
|
||||||
update_freq_ctr(&fe->fe_conn_per_sec, 1));
|
update_freq_ctr(&fe->fe_counters.conn_per_sec, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* increase the number of cumulated connections accepted by the designated frontend */
|
/* increase the number of cumulated connections accepted by the designated frontend */
|
||||||
@ -145,7 +145,7 @@ static inline void proxy_inc_fe_sess_ctr(struct listener *l, struct proxy *fe)
|
|||||||
if (l && l->counters)
|
if (l && l->counters)
|
||||||
_HA_ATOMIC_INC(&l->counters->cum_sess);
|
_HA_ATOMIC_INC(&l->counters->cum_sess);
|
||||||
HA_ATOMIC_UPDATE_MAX(&fe->fe_counters.sps_max,
|
HA_ATOMIC_UPDATE_MAX(&fe->fe_counters.sps_max,
|
||||||
update_freq_ctr(&fe->fe_sess_per_sec, 1));
|
update_freq_ctr(&fe->fe_counters.sess_per_sec, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* increase the number of cumulated HTTP sessions on the designated frontend.
|
/* increase the number of cumulated HTTP sessions on the designated frontend.
|
||||||
@ -168,7 +168,7 @@ static inline void proxy_inc_be_ctr(struct proxy *be)
|
|||||||
{
|
{
|
||||||
_HA_ATOMIC_INC(&be->be_counters.cum_sess);
|
_HA_ATOMIC_INC(&be->be_counters.cum_sess);
|
||||||
HA_ATOMIC_UPDATE_MAX(&be->be_counters.sps_max,
|
HA_ATOMIC_UPDATE_MAX(&be->be_counters.sps_max,
|
||||||
update_freq_ctr(&be->be_sess_per_sec, 1));
|
update_freq_ctr(&be->be_counters.sess_per_sec, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* increase the number of cumulated requests on the designated frontend.
|
/* increase the number of cumulated requests on the designated frontend.
|
||||||
@ -185,7 +185,7 @@ static inline void proxy_inc_fe_req_ctr(struct listener *l, struct proxy *fe,
|
|||||||
if (l && l->counters)
|
if (l && l->counters)
|
||||||
_HA_ATOMIC_INC(&l->counters->p.http.cum_req[http_ver]);
|
_HA_ATOMIC_INC(&l->counters->p.http.cum_req[http_ver]);
|
||||||
HA_ATOMIC_UPDATE_MAX(&fe->fe_counters.p.http.rps_max,
|
HA_ATOMIC_UPDATE_MAX(&fe->fe_counters.p.http.rps_max,
|
||||||
update_freq_ctr(&fe->fe_req_per_sec, 1));
|
update_freq_ctr(&fe->fe_counters.req_per_sec, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns non-zero if the proxy is configured to retry a request if we got that status, 0 otherwise */
|
/* Returns non-zero if the proxy is configured to retry a request if we got that status, 0 otherwise */
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
#include <haproxy/check-t.h>
|
#include <haproxy/check-t.h>
|
||||||
#include <haproxy/connection-t.h>
|
#include <haproxy/connection-t.h>
|
||||||
#include <haproxy/counters-t.h>
|
#include <haproxy/counters-t.h>
|
||||||
#include <haproxy/freq_ctr-t.h>
|
|
||||||
#include <haproxy/guid-t.h>
|
#include <haproxy/guid-t.h>
|
||||||
#include <haproxy/listener-t.h>
|
#include <haproxy/listener-t.h>
|
||||||
#include <haproxy/obj_type-t.h>
|
#include <haproxy/obj_type-t.h>
|
||||||
@ -366,7 +365,6 @@ struct server {
|
|||||||
int cur_sess; /* number of currently active sessions (including syn_sent) */
|
int cur_sess; /* number of currently active sessions (including syn_sent) */
|
||||||
int served; /* # of active sessions currently being served (ie not pending) */
|
int served; /* # of active sessions currently being served (ie not pending) */
|
||||||
int consecutive_errors; /* current number of consecutive errors */
|
int consecutive_errors; /* current number of consecutive errors */
|
||||||
struct freq_ctr sess_per_sec; /* sessions per second on this server */
|
|
||||||
struct be_counters counters; /* statistics counters */
|
struct be_counters counters; /* statistics counters */
|
||||||
|
|
||||||
/* Below are some relatively stable settings, only changed under the lock */
|
/* Below are some relatively stable settings, only changed under the lock */
|
||||||
|
@ -181,7 +181,7 @@ static inline void srv_inc_sess_ctr(struct server *s)
|
|||||||
{
|
{
|
||||||
_HA_ATOMIC_INC(&s->counters.cum_sess);
|
_HA_ATOMIC_INC(&s->counters.cum_sess);
|
||||||
HA_ATOMIC_UPDATE_MAX(&s->counters.sps_max,
|
HA_ATOMIC_UPDATE_MAX(&s->counters.sps_max,
|
||||||
update_freq_ctr(&s->sess_per_sec, 1));
|
update_freq_ctr(&s->counters.sess_per_sec, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set the time of last session on the designated server */
|
/* set the time of last session on the designated server */
|
||||||
|
@ -3080,7 +3080,7 @@ smp_fetch_be_sess_rate(const struct arg *args, struct sample *smp, const char *k
|
|||||||
|
|
||||||
smp->flags = SMP_F_VOL_TEST;
|
smp->flags = SMP_F_VOL_TEST;
|
||||||
smp->data.type = SMP_T_SINT;
|
smp->data.type = SMP_T_SINT;
|
||||||
smp->data.u.sint = read_freq_ctr(&px->be_sess_per_sec);
|
smp->data.u.sint = read_freq_ctr(&px->be_counters.sess_per_sec);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3263,7 +3263,7 @@ smp_fetch_srv_sess_rate(const struct arg *args, struct sample *smp, const char *
|
|||||||
{
|
{
|
||||||
smp->flags = SMP_F_VOL_TEST;
|
smp->flags = SMP_F_VOL_TEST;
|
||||||
smp->data.type = SMP_T_SINT;
|
smp->data.type = SMP_T_SINT;
|
||||||
smp->data.u.sint = read_freq_ctr(&args->data.srv->sess_per_sec);
|
smp->data.u.sint = read_freq_ctr(&args->data.srv->counters.sess_per_sec);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,7 +252,7 @@ smp_fetch_fe_req_rate(const struct arg *args, struct sample *smp, const char *kw
|
|||||||
|
|
||||||
smp->flags = SMP_F_VOL_TEST;
|
smp->flags = SMP_F_VOL_TEST;
|
||||||
smp->data.type = SMP_T_SINT;
|
smp->data.type = SMP_T_SINT;
|
||||||
smp->data.u.sint = read_freq_ctr(&px->fe_req_per_sec);
|
smp->data.u.sint = read_freq_ctr(&px->fe_counters.req_per_sec);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,7 +272,7 @@ smp_fetch_fe_sess_rate(const struct arg *args, struct sample *smp, const char *k
|
|||||||
|
|
||||||
smp->flags = SMP_F_VOL_TEST;
|
smp->flags = SMP_F_VOL_TEST;
|
||||||
smp->data.type = SMP_T_SINT;
|
smp->data.type = SMP_T_SINT;
|
||||||
smp->data.u.sint = read_freq_ctr(&px->fe_sess_per_sec);
|
smp->data.u.sint = read_freq_ctr(&px->fe_counters.sess_per_sec);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1070,11 +1070,11 @@ void listener_accept(struct listener *l)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (p && p->fe_sps_lim) {
|
if (p && p->fe_sps_lim) {
|
||||||
int max = freq_ctr_remain(&p->fe_sess_per_sec, p->fe_sps_lim, 0);
|
int max = freq_ctr_remain(&p->fe_counters.sess_per_sec, p->fe_sps_lim, 0);
|
||||||
|
|
||||||
if (unlikely(!max)) {
|
if (unlikely(!max)) {
|
||||||
/* frontend accept rate limit was reached */
|
/* frontend accept rate limit was reached */
|
||||||
expire = tick_add(now_ms, next_event_delay(&p->fe_sess_per_sec, p->fe_sps_lim, 0));
|
expire = tick_add(now_ms, next_event_delay(&p->fe_counters.sess_per_sec, p->fe_sps_lim, 0));
|
||||||
goto limit_proxy;
|
goto limit_proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1545,7 +1545,7 @@ void listener_accept(struct listener *l)
|
|||||||
dequeue_all_listeners();
|
dequeue_all_listeners();
|
||||||
|
|
||||||
if (p && !MT_LIST_ISEMPTY(&p->listener_queue) &&
|
if (p && !MT_LIST_ISEMPTY(&p->listener_queue) &&
|
||||||
(!p->fe_sps_lim || freq_ctr_remain(&p->fe_sess_per_sec, p->fe_sps_lim, 0) > 0))
|
(!p->fe_sps_lim || freq_ctr_remain(&p->fe_counters.sess_per_sec, p->fe_sps_lim, 0) > 0))
|
||||||
dequeue_proxy_listeners(p);
|
dequeue_proxy_listeners(p);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -1604,14 +1604,14 @@ void listener_release(struct listener *l)
|
|||||||
dequeue_all_listeners();
|
dequeue_all_listeners();
|
||||||
|
|
||||||
if (fe && !MT_LIST_ISEMPTY(&fe->listener_queue) &&
|
if (fe && !MT_LIST_ISEMPTY(&fe->listener_queue) &&
|
||||||
(!fe->fe_sps_lim || freq_ctr_remain(&fe->fe_sess_per_sec, fe->fe_sps_lim, 0) > 0))
|
(!fe->fe_sps_lim || freq_ctr_remain(&fe->fe_counters.sess_per_sec, fe->fe_sps_lim, 0) > 0))
|
||||||
dequeue_proxy_listeners(fe);
|
dequeue_proxy_listeners(fe);
|
||||||
else {
|
else {
|
||||||
unsigned int wait;
|
unsigned int wait;
|
||||||
int expire = TICK_ETERNITY;
|
int expire = TICK_ETERNITY;
|
||||||
|
|
||||||
if (fe->task && fe->fe_sps_lim &&
|
if (fe->task && fe->fe_sps_lim &&
|
||||||
(wait = next_event_delay(&fe->fe_sess_per_sec,fe->fe_sps_lim, 0))) {
|
(wait = next_event_delay(&fe->fe_counters.sess_per_sec,fe->fe_sps_lim, 0))) {
|
||||||
/* we're blocking because a limit was reached on the number of
|
/* we're blocking because a limit was reached on the number of
|
||||||
* requests/s on the frontend. We want to re-check ASAP, which
|
* requests/s on the frontend. We want to re-check ASAP, which
|
||||||
* means in 1 ms before estimated expiration date, because the
|
* means in 1 ms before estimated expiration date, because the
|
||||||
|
@ -1980,7 +1980,7 @@ struct task *manage_proxy(struct task *t, void *context, unsigned int state)
|
|||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (p->fe_sps_lim &&
|
if (p->fe_sps_lim &&
|
||||||
(wait = next_event_delay(&p->fe_sess_per_sec, p->fe_sps_lim, 0))) {
|
(wait = next_event_delay(&p->fe_counters.sess_per_sec, p->fe_sps_lim, 0))) {
|
||||||
/* we're blocking because a limit was reached on the number of
|
/* we're blocking because a limit was reached on the number of
|
||||||
* requests/s on the frontend. We want to re-check ASAP, which
|
* requests/s on the frontend. We want to re-check ASAP, which
|
||||||
* means in 1 ms before estimated expiration date, because the
|
* means in 1 ms before estimated expiration date, because the
|
||||||
|
10
src/stats.c
10
src/stats.c
@ -877,7 +877,7 @@ int stats_fill_fe_line(struct proxy *px, int flags, struct field *line, int len,
|
|||||||
field = mkf_u32(FO_CONFIG|FS_SERVICE, STATS_TYPE_FE);
|
field = mkf_u32(FO_CONFIG|FS_SERVICE, STATS_TYPE_FE);
|
||||||
break;
|
break;
|
||||||
case ST_I_PX_RATE:
|
case ST_I_PX_RATE:
|
||||||
field = mkf_u32(FN_RATE, read_freq_ctr(&px->fe_sess_per_sec));
|
field = mkf_u32(FN_RATE, read_freq_ctr(&px->fe_counters.sess_per_sec));
|
||||||
break;
|
break;
|
||||||
case ST_I_PX_RATE_LIM:
|
case ST_I_PX_RATE_LIM:
|
||||||
field = mkf_u32(FO_CONFIG|FN_LIMIT, px->fe_sps_lim);
|
field = mkf_u32(FO_CONFIG|FN_LIMIT, px->fe_sps_lim);
|
||||||
@ -886,13 +886,13 @@ int stats_fill_fe_line(struct proxy *px, int flags, struct field *line, int len,
|
|||||||
field = mkf_u32(FN_MAX, px->fe_counters.sps_max);
|
field = mkf_u32(FN_MAX, px->fe_counters.sps_max);
|
||||||
break;
|
break;
|
||||||
case ST_I_PX_REQ_RATE:
|
case ST_I_PX_REQ_RATE:
|
||||||
field = mkf_u32(FN_RATE, read_freq_ctr(&px->fe_req_per_sec));
|
field = mkf_u32(FN_RATE, read_freq_ctr(&px->fe_counters.req_per_sec));
|
||||||
break;
|
break;
|
||||||
case ST_I_PX_REQ_RATE_MAX:
|
case ST_I_PX_REQ_RATE_MAX:
|
||||||
field = mkf_u32(FN_MAX, px->fe_counters.p.http.rps_max);
|
field = mkf_u32(FN_MAX, px->fe_counters.p.http.rps_max);
|
||||||
break;
|
break;
|
||||||
case ST_I_PX_CONN_RATE:
|
case ST_I_PX_CONN_RATE:
|
||||||
field = mkf_u32(FN_RATE, read_freq_ctr(&px->fe_conn_per_sec));
|
field = mkf_u32(FN_RATE, read_freq_ctr(&px->fe_counters.conn_per_sec));
|
||||||
break;
|
break;
|
||||||
case ST_I_PX_CONN_RATE_MAX:
|
case ST_I_PX_CONN_RATE_MAX:
|
||||||
field = mkf_u32(FN_MAX, px->fe_counters.cps_max);
|
field = mkf_u32(FN_MAX, px->fe_counters.cps_max);
|
||||||
@ -1364,7 +1364,7 @@ int stats_fill_sv_line(struct proxy *px, struct server *sv, int flags,
|
|||||||
field = mkf_u32(FO_CONFIG|FS_SERVICE, STATS_TYPE_SV);
|
field = mkf_u32(FO_CONFIG|FS_SERVICE, STATS_TYPE_SV);
|
||||||
break;
|
break;
|
||||||
case ST_I_PX_RATE:
|
case ST_I_PX_RATE:
|
||||||
field = mkf_u32(FN_RATE, read_freq_ctr(&sv->sess_per_sec));
|
field = mkf_u32(FN_RATE, read_freq_ctr(&sv->counters.sess_per_sec));
|
||||||
break;
|
break;
|
||||||
case ST_I_PX_RATE_MAX:
|
case ST_I_PX_RATE_MAX:
|
||||||
field = mkf_u32(FN_MAX, sv->counters.sps_max);
|
field = mkf_u32(FN_MAX, sv->counters.sps_max);
|
||||||
@ -1710,7 +1710,7 @@ int stats_fill_be_line(struct proxy *px, int flags, struct field *line, int len,
|
|||||||
field = mkf_u32(FO_CONFIG|FS_SERVICE, STATS_TYPE_BE);
|
field = mkf_u32(FO_CONFIG|FS_SERVICE, STATS_TYPE_BE);
|
||||||
break;
|
break;
|
||||||
case ST_I_PX_RATE:
|
case ST_I_PX_RATE:
|
||||||
field = mkf_u32(0, read_freq_ctr(&px->be_sess_per_sec));
|
field = mkf_u32(0, read_freq_ctr(&px->be_counters.sess_per_sec));
|
||||||
break;
|
break;
|
||||||
case ST_I_PX_RATE_MAX:
|
case ST_I_PX_RATE_MAX:
|
||||||
field = mkf_u32(0, px->be_counters.sps_max);
|
field = mkf_u32(0, px->be_counters.sps_max);
|
||||||
|
Loading…
Reference in New Issue
Block a user