Consider dropping the JSON_C_TO_STRING_PRETTY flag used for generating JSON statistics
JSON is a machine-readable format, so there is no need to generate statschannel output in a "pretty" form. Quick experiments show that redundant whitespace adds up to about 40% of the JSON payload produced by statschannel code.
Yes, lib/isc/httpd.c
supports DEFLATE compression via zlib and that
enables massive savings in terms of payload size, but it requires
clients to send the Accept-Encoding: deflate
HTTP header in order to
kick in, so IMHO HTTP-level compression and producing "minified" JSON
data are tangential mechanisms rather than exclusive alternatives.
Piping "minified" JSON through jq
allows one to get the "pretty" form
without the extra bandwidth cost.
Some semi-random measurements:
-
v9.19, 4 logical CPU cores
$ curl -s http://localhost:8080/json | wc -c 71386 $ curl -s http://localhost:8080/json | jq -c | wc -c 41881 $ curl -s -H "Accept-Encoding: deflate" http://localhost:8080/json | wc -c 4150
-
v9.19, 32 logical CPU cores
$ curl -s http://localhost:8080/json | wc -c 391217 $ curl -s http://localhost:8080/json | jq -c | wc -c 227837 $ curl -s -H "Accept-Encoding: deflate" http://localhost:8080/json | wc -c 16721
-
v9.16, 4 logical CPU cores
$ curl -s http://localhost:8080/json | wc -c 896972 $ curl -s http://localhost:8080/json | jq -c | wc -c 529643 $ curl -s -H "Accept-Encoding: deflate" http://localhost:8080/json | wc -c 25880
-
v9.16, 32 logical CPU cores
$ curl -s http://localhost:8080/json | wc -c 6954362 $ curl -s http://localhost:8080/json | jq -c | wc -c 4106064 $ curl -s -H "Accept-Encoding: deflate" http://localhost:8080/json | wc -c 174557