From: Christopher Faulet Date: Tue, 9 Jul 2024 05:49:49 +0000 (+0200) Subject: MINOR: stats-html: Display reuse ratio for spop connections X-Git-Tag: v3.1-dev4~68 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=6b9daec93d89c949130c06219a8b24239bb406b2;p=haproxy.git MINOR: stats-html: Display reuse ratio for spop connections Now SPOP connections can be reused, it could be pretty useful to know the reuse rate. The corresponding backend and server counters are already incremented, but not displayed on the stats HTML page. Thanks to this patch, it is now possible to get it, just like for HTTP proxies. The related issue is #2502. --- diff --git a/src/stats-html.c b/src/stats-html.c index 41eaa9e89..e27ff8e40 100644 --- a/src/stats-html.c +++ b/src/stats-html.c @@ -944,6 +944,16 @@ int stats_dump_fields_html(struct buffer *out, U2H(stats[ST_I_PX_WREW].u.u64), U2H(stats[ST_I_PX_EINT].u.u64)); } + else if (strcmp(field_str(stats, ST_I_PX_MODE), "spop") == 0) { + chunk_appendf(out, + "New connections:%s" + "Reused connections:%s(%d%%)" + "", + U2H(stats[ST_I_PX_CONNECT].u.u64), + U2H(stats[ST_I_PX_REUSE].u.u64), + (stats[ST_I_PX_CONNECT].u.u64 + stats[ST_I_PX_REUSE].u.u64) ? + (int)(100 * stats[ST_I_PX_REUSE].u.u64 / (stats[ST_I_PX_CONNECT].u.u64 + stats[ST_I_PX_REUSE].u.u64)) : 0); + } chunk_appendf(out, "Max / Avg over last 1024 success. conn."); chunk_appendf(out, "- Queue time:%s / %sms", @@ -1211,6 +1221,16 @@ int stats_dump_fields_html(struct buffer *out, U2H(stats[ST_I_PX_WREW].u.u64), U2H(stats[ST_I_PX_EINT].u.u64)); } + else if (strcmp(field_str(stats, ST_I_PX_MODE), "spop") == 0) { + chunk_appendf(out, + "New connections:%s" + "Reused connections:%s(%d%%)" + "", + U2H(stats[ST_I_PX_CONNECT].u.u64), + U2H(stats[ST_I_PX_REUSE].u.u64), + (stats[ST_I_PX_CONNECT].u.u64 + stats[ST_I_PX_REUSE].u.u64) ? + (int)(100 * stats[ST_I_PX_REUSE].u.u64 / (stats[ST_I_PX_CONNECT].u.u64 + stats[ST_I_PX_REUSE].u.u64)) : 0); + } chunk_appendf(out, "Max / Avg over last 1024 success. conn."); chunk_appendf(out, "- Queue time:%s / %sms", diff --git a/src/stats-proxy.c b/src/stats-proxy.c index a158d87cf..bfc072953 100644 --- a/src/stats-proxy.c +++ b/src/stats-proxy.c @@ -118,7 +118,7 @@ const struct stat_col stat_cols_px[ST_I_PX_MAX] = { [ST_I_PX_AGENT_HEALTH] = { .name = "agent_health", .desc = "Current server agent check level (0..fall-1=DOWN, fall..rise-1=UP)" }, [ST_I_PX_ADDR] = { .name = "addr", .desc = "Server's address:port, shown only if show-legends is set, or at levels oper/admin for the CLI" }, [ST_I_PX_COOKIE] = { .name = "cookie", .desc = "Backend's cookie name or Server's cookie value, shown only if show-legends is set, or at levels oper/admin for the CLI" }, - [ST_I_PX_MODE] = { .name = "mode", .desc = "'mode' setting (tcp/http/health/cli)" }, + [ST_I_PX_MODE] = { .name = "mode", .desc = "'mode' setting (tcp/http/health/cli/spop)" }, [ST_I_PX_ALGO] = { .name = "algo", .desc = "Backend's load balancing algorithm, shown only if show-legends is set, or at levels oper/admin for the CLI" }, [ST_I_PX_CONN_RATE] = ME_NEW_FE("conn_rate", FN_RATE, FF_U32, conn_per_sec, STATS_PX_CAP__F__, "Number of new connections accepted over the last second on the frontend for this worker process"), [ST_I_PX_CONN_RATE_MAX] = { .name = "conn_rate_max", .desc = "Highest value of connections per second observed since the worker process started" },