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:

  • tokers/zstd-nginx-module: as shipped, commit 057a7d3 with libzstd 1.5.7.
  • ngx_mzstd, event loop: ngx_mzstd with its default settings, compressing in the worker’s event loop like tokers/zstd-nginx-module.
  • ngx_mzstd, pool, 1 task and 4 tasks: ngx_mzstd with zstd_thread_pool on a pool of 4 threads and zstd_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 zstd_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 tokers/zstd-nginx-module.

ResponseLeveltokers/zstd-nginx-modulengx_mzstd, event loopngx_mzstd, pool, 1 taskngx_mzstd, pool, 4 tasks
small.json, 1.9 KB333,24347,777 (1.44×)36,934 (1.11×)42,453 (1.28×)
small.json, 1.9 KB93,96836,116 (9.10×)43,643 (11.0×)38,706 (9.76×)
small.json, 1.9 KB1558.49,130 (156×)28,397 (487×)28,112 (482×)
small.json, 1.9 KB1946.05,070 (110×)16,393 (357×)16,152 (351×)
jquery.min.js, 85 KB33,4664,138 (1.19×)12,967 (3.74×)12,762 (3.68×)
jquery.min.js, 85 KB9841855 (1.02×)3,312 (3.94×)3,298 (3.92×)
jquery.min.js, 85 KB1550.2200 (3.99×)763 (15.2×)762 (15.2×)
jquery.min.js, 85 KB1931.283.8 (2.68×)321 (10.3×)323 (10.3×)
react-dom.development.js, 1.03 MB3359423 (1.18×)1,325 (3.69×)1,325 (3.69×)
react-dom.development.js, 1.03 MB991.392.9 (1.02×)257 (2.81×)244 (2.67×)
react-dom.development.js, 1.03 MB1512.115.6 (1.29×)46.2 (3.82×)45.7 (3.77×)
react-dom.development.js, 1.03 MB194.996.34 (1.27×)16.3 (3.27×)16.0 (3.21×)
libraries.json, 2.2 MB3175209 (1.19×)647 (3.69×)665 (3.79×)
libraries.json, 2.2 MB948.449.7 (1.03×)118 (2.43×)114 (2.35×)
libraries.json, 2.2 MB156.997.74 (1.11×)18.5 (2.64×)15.5 (2.21×)
libraries.json, 2.2 MB192.372.95 (1.24×)6.29 (2.65×)6.39 (2.70×)

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, because every segment but the first also runs through part of the input before it.

ResponseLeveltokers/zstd-nginx-modulengx_mzstd, event loopngx_mzstd, pool, 1 taskngx_mzstd, pool, 4 tasks
small.json, 1.9 KB30.0300.0210.0390.035
small.json, 1.9 KB90.2510.0280.0410.045
small.json, 1.9 KB1517.70.1100.1210.120
small.json, 1.9 KB1921.90.1970.2100.210
jquery.min.js, 85 KB30.2890.2420.2670.268
jquery.min.js, 85 KB91.191.171.181.18
jquery.min.js, 85 KB1520.55.045.255.23
jquery.min.js, 85 KB1932.412.012.512.4
react-dom.development.js, 1.03 MB32.782.372.902.93
react-dom.development.js, 1.03 MB910.910.815.616.4
react-dom.development.js, 1.03 MB1583.964.786.888.6
react-dom.development.js, 1.03 MB19201159246252
libraries.json, 2.2 MB35.714.785.796.01
libraries.json, 2.2 MB920.720.134.035.3
libraries.json, 2.2 MB15146130221269
libraries.json, 2.2 MB19424342641640

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.

ResponseLeveltokers/zstd-nginx-modulengx_mzstd, event loopngx_mzstd, pool, 1 taskngx_mzstd, pool, 4 tasks
small.json, 1.9 KB35566
small.json, 1.9 KB914566
small.json, 1.9 KB1568577
small.json, 1.9 KB1985577
jquery.min.js, 85 KB3561717
jquery.min.js, 85 KB91561818
jquery.min.js, 85 KB156883131
jquery.min.js, 85 KB198582830
react-dom.development.js, 1.03 MB3675166
react-dom.development.js, 1.03 MB91616159209
react-dom.development.js, 1.03 MB156938413549
react-dom.development.js, 1.03 MB198639443562
libraries.json, 2.2 MB3785986
libraries.json, 2.2 MB91717173291
libraries.json, 2.2 MB1570715231,119
libraries.json, 2.2 MB198756505937

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.
  • tokers/zstd-nginx-module at commit 057a7d3 with libzstd 1.5.7.
  • ngx_mzstd 0.2.3 with mzstd 0.2.9, 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, zstd_thread_pool cp with zstd_parallel_tasks 1 or 4. Everything else is left at its default, including zstd_parallel_segment_size 1m, zstd_parallel_compressors 4 and zstd_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 19), 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 zstd 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.