MINOR: stats: report HTTP compression stats per frontend and per backend
It was a bit frustrating to have no idea about the bandwidth saved by
HTTP compression. Now we have per-frontend and per-backend stats. The
stats on the HTTP interface are shown in a hover title in the "bytes out"
column if at least something was fed to the compressor. 3 new columns
appeared in the CSV stats output.
diff --git a/doc/configuration.txt b/doc/configuration.txt
index 663ffde..23b6798 100644
--- a/doc/configuration.txt
+++ b/doc/configuration.txt
@@ -11026,6 +11026,9 @@
48. req_tot: total number of HTTP requests received
49. cli_abrt: number of data transfers aborted by the client
50. srv_abrt: number of data transfers aborted by the server (inc. in eresp)
+ 51. comp_in: number of HTTP response bytes fed to the compressor
+ 52. comp_out: number of HTTP response bytes emitted by the compressor
+ 53. comp_byp: number of bytes that bypassed the HTTP compressor (CPU/BW limit)
9.2. Unix Socket commands
diff --git a/include/types/counters.h b/include/types/counters.h
index 391915a..8326429 100644
--- a/include/types/counters.h
+++ b/include/types/counters.h
@@ -37,6 +37,10 @@
long long bytes_in; /* number of bytes transferred from the client to the server */
long long bytes_out; /* number of bytes transferred from the server to the client */
+ long long comp_in; /* input bytes fed to the compressor */
+ long long comp_out; /* output bytes emitted by the compressor */
+ long long comp_byp; /* input bytes that bypassed the compressor (cpu/ram/bw limitation) */
+
long long denied_req; /* blocked requests/responses because of security concerns */
long long denied_resp; /* blocked requests/responses because of security concerns */
long long failed_req; /* failed requests (eg: invalid or timeout) */
diff --git a/src/compression.c b/src/compression.c
index 0459aa3..3622d40 100644
--- a/src/compression.c
+++ b/src/compression.c
@@ -217,7 +217,7 @@
*/
int http_compression_buffer_end(struct session *s, struct buffer **in, struct buffer **out, int end)
{
- int to_forward;
+ int to_forward, forwarded;
int left;
struct http_msg *msg = &s->txn.rsp;
struct buffer *ib = *in, *ob = *out;
@@ -262,9 +262,17 @@
}
to_forward = ob->i;
+
/* update input rate */
- if (s->comp_ctx && s->comp_ctx->cur_lvl > 0)
- update_freq_ctr(&global.comp_bps_in, ib->o - ob->o);
+ forwarded = ib->o - ob->o;
+ if (s->comp_ctx && s->comp_ctx->cur_lvl > 0) {
+ update_freq_ctr(&global.comp_bps_in, forwarded);
+ s->fe->fe_counters.comp_in += forwarded;
+ s->be->be_counters.comp_in += forwarded;
+ } else {
+ s->fe->fe_counters.comp_byp += forwarded;
+ s->be->be_counters.comp_byp += forwarded;
+ }
/* copy the remaining data in the tmp buffer. */
if (ib->i > 0) {
@@ -281,8 +289,11 @@
*in = ob;
*out = ib;
- if (s->comp_ctx && s->comp_ctx->cur_lvl > 0)
+ if (s->comp_ctx && s->comp_ctx->cur_lvl > 0) {
update_freq_ctr(&global.comp_bps_out, to_forward);
+ s->fe->fe_counters.comp_out += to_forward;
+ s->be->be_counters.comp_out += to_forward;
+ }
/* forward the new chunk without remaining data */
b_adv(ob, to_forward);
diff --git a/src/dumpstats.c b/src/dumpstats.c
index 997bdec..a9ecdb3 100644
--- a/src/dumpstats.c
+++ b/src/dumpstats.c
@@ -379,6 +379,7 @@
"hrsp_1xx,hrsp_2xx,hrsp_3xx,hrsp_4xx,hrsp_5xx,hrsp_other,hanafail,"
"req_rate,req_rate_max,req_tot,"
"cli_abrt,srv_abrt,"
+ "comp_in, comp_out, comp_byp,"
"\n");
}
@@ -2477,15 +2478,27 @@
chunk_appendf(&trash,
/* sessions: total, lbtot */
">%s%s%s</td><td></td>"
- /* bytes : in, out */
- "<td>%s</td><td>%s</td>"
+ /* bytes : in */
+ "<td>%s</td><td"
"",
(px->mode == PR_MODE_HTTP)?"<u>":"",
U2H6(px->fe_counters.cum_sess),
(px->mode == PR_MODE_HTTP)?"</u>":"",
- U2H7(px->fe_counters.bytes_in), U2H8(px->fe_counters.bytes_out));
+ U2H7(px->fe_counters.bytes_in));
+
+ /* compression stats (via td title): comp_in, comp_out, comp_byp */
+ chunk_appendf(&trash, " title=\"compression: in=%lld out=%lld bypassed=%lld\"",
+ px->fe_counters.comp_in, px->fe_counters.comp_out, px->fe_counters.comp_byp);
chunk_appendf(&trash,
+ /* bytes: out */
+ ">%s%s%s</td>"
+ "",
+ (px->fe_counters.comp_in || px->fe_counters.comp_byp) ? "<u>":"",
+ U2H0(px->fe_counters.bytes_out),
+ (px->fe_counters.comp_in || px->fe_counters.comp_byp) ? "</u>":"");
+
+ chunk_appendf(&trash,
/* denied: req, resp */
"<td>%s</td><td>%s</td>"
/* errors : request, connect, response */
@@ -2559,6 +2572,10 @@
/* errors: cli_aborts, srv_aborts */
chunk_appendf(&trash, ",,");
+ /* compression: in, out, bypassed */
+ chunk_appendf(&trash, "%lld,%lld,%lld,",
+ px->fe_counters.comp_in, px->fe_counters.comp_out, px->fe_counters.comp_byp);
+
/* finish with EOL */
chunk_appendf(&trash, "\n");
}
@@ -3186,16 +3203,28 @@
chunk_appendf(&trash,
/* sessions: total, lbtot */
">%s%s%s</td><td>%s</td>"
- /* bytes: in, out */
- "<td>%s</td><td>%s</td>"
+ /* bytes: in */
+ "<td>%s</td><td"
"",
(px->mode == PR_MODE_HTTP)?"<u>":"",
U2H6(px->be_counters.cum_conn),
(px->mode == PR_MODE_HTTP)?"</u>":"",
U2H7(px->be_counters.cum_lbconn),
- U2H8(px->be_counters.bytes_in), U2H9(px->be_counters.bytes_out));
+ U2H8(px->be_counters.bytes_in));
+
+ /* compression stats (via td title): comp_in, comp_out, comp_byp */
+ chunk_appendf(&trash, " title=\"compression: in=%lld out=%lld bypassed=%lld\"",
+ px->be_counters.comp_in, px->be_counters.comp_out, px->be_counters.comp_byp);
chunk_appendf(&trash,
+ /* bytes: out */
+ ">%s%s%s</td>"
+ "",
+ (px->be_counters.comp_in || px->be_counters.comp_byp) ? "<u>":"",
+ U2H0(px->be_counters.bytes_out),
+ (px->be_counters.comp_in || px->be_counters.comp_byp) ? "</u>":"");
+
+ chunk_appendf(&trash,
/* denied: req, resp */
"<td>%s</td><td>%s</td>"
/* errors : request, connect */
@@ -3300,6 +3329,10 @@
chunk_appendf(&trash, "%lld,%lld,",
px->be_counters.cli_aborts, px->be_counters.srv_aborts);
+ /* compression: in, out, bypassed */
+ chunk_appendf(&trash, "%lld,%lld,%lld,",
+ px->be_counters.comp_in, px->be_counters.comp_out, px->be_counters.comp_byp);
+
/* finish with EOL */
chunk_appendf(&trash, "\n");