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.
This commit is contained in:
Willy Tarreau 2012-11-21 08:27:21 +01:00
parent 83d84cfc8a
commit 55058a7c1e
4 changed files with 61 additions and 10 deletions

View File

@ -11026,6 +11026,9 @@ page. Both means provide a CSV format whose fields follow.
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

View File

@ -37,6 +37,10 @@ struct pxcounters {
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) */

View File

@ -217,7 +217,7 @@ int http_compression_buffer_add_data(struct session *s, struct buffer *in, struc
*/
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 @@ int http_compression_buffer_end(struct session *s, struct buffer **in, struct bu
}
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 @@ int http_compression_buffer_end(struct session *s, struct buffer **in, struct bu
*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);

View File

@ -379,6 +379,7 @@ static int print_csv_header(struct chunk *msg)
"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,13 +2478,25 @@ static int stats_dump_proxy(struct stream_interface *si, struct proxy *px, struc
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 */
@ -2559,6 +2572,10 @@ static int stats_dump_proxy(struct stream_interface *si, struct proxy *px, struc
/* 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,14 +3203,26 @@ static int stats_dump_proxy(struct stream_interface *si, struct proxy *px, struc
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 */
@ -3300,6 +3329,10 @@ static int stats_dump_proxy(struct stream_interface *si, struct proxy *px, struc
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");