Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Benchmarks

One NGINX worker compresses static files on the fly for 8 connections at once, in four setups:

  • google/ngx_brotli: as shipped, commit a71f9312 with the Brotli 1.1.0 it pins as a submodule.
  • ngx_mbrotli, event loop: ngx_mbrotli with its default settings, compressing in the worker’s event loop like google/ngx_brotli.
  • ngx_mbrotli, pool, 1 task and 4 tasks: ngx_mbrotli with brotli_thread_pool on a pool of 4 threads and brotli_parallel_tasks 1 or 4 (the default), so that one response is compressed by up to 1 or 4 threads at once, in 1m segments.

Only brotli_comp_level changes from row to row. The worker and its pool share 4 CPUs. Each number is the median of three runs under WSL2 (see Hardware, build and method): good for comparing the setups with each other, less so as absolute numbers.

Requests per second

Higher is better. In brackets, relative to google/ngx_brotli.

ResponseLevelgoogle/ngx_brotlingx_mbrotli, event loopngx_mbrotli, pool, 1 taskngx_mbrotli, pool, 4 tasks
small.json, 1.9 KB428,37031,114 (1.10×)41,653 (1.47×)42,238 (1.49×)
small.json, 1.9 KB612,75028,301 (2.22×)41,624 (3.26×)41,483 (3.25×)
small.json, 1.9 KB923,21824,194 (1.04×)40,078 (1.73×)36,406 (1.57×)
small.json, 1.9 KB11613965 (1.57×)3,717 (6.06×)3,714 (6.06×)
jquery.min.js, 85 KB49551,145 (1.20×)4,196 (4.39×)4,177 (4.37×)
jquery.min.js, 85 KB6655717 (1.10×)2,603 (3.98×)2,559 (3.91×)
jquery.min.js, 85 KB9104442 (4.24×)1,552 (14.9×)1,452 (13.9×)
jquery.min.js, 85 KB1114.525.4 (1.75×)100.0 (6.88×)99.9 (6.88×)
react-dom.development.js, 1.03 MB4130152 (1.17×)443 (3.41×)448 (3.45×)
react-dom.development.js, 1.03 MB661.579.4 (1.29×)261 (4.24×)265 (4.30×)
react-dom.development.js, 1.03 MB924.042.6 (1.78×)111 (4.63×)128 (5.33×)
react-dom.development.js, 1.03 MB111.001.70 (1.70×)9.93 (9.93×)9.96 (9.96×)
libraries.json, 2.2 MB467.176.9 (1.15×)232 (3.45×)240 (3.58×)
libraries.json, 2.2 MB631.940.8 (1.28×)135 (4.24×)133 (4.16×)
libraries.json, 2.2 MB914.021.6 (1.54×)65.1 (4.65×)63.5 (4.54×)
libraries.json, 2.2 MB110.5200.900 (1.73×)5.27 (10.1×)5.39 (10.4×)

CPU time per request

The worker’s user and system CPU time per request, including the pool’s threads, in ms. Lower is better. On the pool, responses longer than one segment (1 MB and more here) cost more at levels 4–9, because every segment but the first also runs through part of the input before it, and less at level 11, because 1 MiB segments compress faster than a whole file.

ResponseLevelgoogle/ngx_brotlingx_mbrotli, event loopngx_mbrotli, pool, 1 taskngx_mbrotli, pool, 4 tasks
small.json, 1.9 KB40.0350.0320.0510.050
small.json, 1.9 KB60.0780.0350.0540.054
small.json, 1.9 KB90.0430.0410.0710.075
small.json, 1.9 KB111.631.041.061.06
jquery.min.js, 85 KB41.050.8750.9200.922
jquery.min.js, 85 KB61.531.401.511.53
jquery.min.js, 85 KB99.742.272.552.72
jquery.min.js, 85 KB1170.539.940.140.1
react-dom.development.js, 1.03 MB47.766.609.008.92
react-dom.development.js, 1.03 MB616.512.715.315.1
react-dom.development.js, 1.03 MB943.423.935.131.4
react-dom.development.js, 1.03 MB111,188651405408
libraries.json, 2.2 MB415.113.117.216.7
libraries.json, 2.2 MB632.124.829.530.2
libraries.json, 2.2 MB975.747.661.663.5
libraries.json, 2.2 MB112,5221,207765766

Peak memory

The worker’s peak resident set size (VmHWM), in MiB. Lower is better. On the thread pool, every response in flight holds encoders for its segments.

ResponseLevelgoogle/ngx_brotlingx_mbrotli, event loopngx_mbrotli, pool, 1 taskngx_mbrotli, pool, 4 tasks
small.json, 1.9 KB45699
small.json, 1.9 KB6561515
small.json, 1.9 KB9672222
small.json, 1.9 KB11662121
jquery.min.js, 85 KB4562222
jquery.min.js, 85 KB6784645
jquery.min.js, 85 KB93684843
jquery.min.js, 85 KB119116768
react-dom.development.js, 1.03 MB4912113141
react-dom.development.js, 1.03 MB61114149169
react-dom.development.js, 1.03 MB93941578500
react-dom.development.js, 1.03 MB112528238264
libraries.json, 2.2 MB4913137220
libraries.json, 2.2 MB61014174273
libraries.json, 2.2 MB939425631,089
libraries.json, 2.2 MB112830376492

Hardware, build and method

Hardware

  • Intel Core i7-13700KF.
  • Ubuntu 22.04.5 under WSL2 2.7.14.0, kernel 6.18.33.2-microsoft-standard-WSL2, on Windows 10.0.26300. WSL2 shows 12 identical cores of 2 threads each and does not expose which of them are performance cores.

Build

  • NGINX 1.30.6, ./configure --with-compat --with-threads --without-http_rewrite_module, gcc 11.4.0, both modules dynamic.
  • google/ngx_brotli at commit a71f9312c2deb28875acc7bacfdd5695a111aa53, with its deps/brotli submodule at ed738e842d2fbdf2d6459e39267a633c4a9b2f5d (Brotli 1.1.0).
  • ngx_mbrotli 0.4.5 with mbrotli 0.5.20, cargo build --release (rustc 1.99.0).

Configuration

worker_processes 1, pinned to 4 CPUs on different physical cores, and thread_pool cp threads=4. On the pool, brotli_thread_pool cp with brotli_parallel_tasks 1 or 4. Everything else is left at its default, including brotli_parallel_segment_size 1m, brotli_parallel_compressors 4 and brotli_retention_policy aggressive. Files are served from tmpfs.

Load

  • wrk 4.1.0 over loopback, without TLS, from 4 other physical cores, with 2 threads and 8 connections, for 4 seconds (8 seconds for files over 1 MB, 5 times longer at level 11), after a 1-second warm-up.
  • Each run starts NGINX anew and waits until the worker has been idle for 300 ms. Three runs in a shuffled order; the tables show the median.
  • CPU time is read from /proc/<pid>/stat of the worker, including the pool’s threads, and peak memory from VmHWM in /proc/<pid>/status.
  • Every response, for every setup, level and file, was decoded with curl’s Brotli decoder and compared with the original file by SHA-256.

Files

jQuery 3.7.1 (jquery.min.js) and React DOM 18.3.1 (react-dom.development.js) from cdnjs, the full cdnjs API listing (libraries.json), and its first 10 entries (small.json), fetched on 2026-10-20. Measured on 2026-11-01.