If you serve web pages, precompress what you can with Brotli at its highest setting and keep gzip as the fallback. If you write backups, logs or build artifacts, switch from gzip to zstd at its default level. If you publish one archive that thousands of people will download, xz and high-level zstd are close on size for source code and text, and zstd unpacks about four times faster; for mixed binary files, xz pulls ahead on size. If your server sends many small, similar pages, a zstd dictionary trained on your own content beat everything else we tried. That is what we found after running five compressors at 17 settings on the Python 3.13.1 source tarball and two standard test sets, then running the six settings that matter for websites across 200 Tech Insider article pages exactly as our server sends them, plus follow-up tests on threads, dictionaries and already-compressed images. Our raw results are downloadable.
The same tool can be the right answer for a backup and the wrong one for a web server, so the results are organized by job, with the exact commands at the end.
| Job | Use | Why, from our tests |
|---|---|---|
| Static web files, compressed at deploy | Brotli 11, with a gzip copy as fallback | 19.1% smaller than gzip -6 across 200 real pages and their CSS/JS |
| Web responses compressed per request | Brotli 5 | 9.0% smaller than gzip -6, and faster to compress |
| Backups, logs, build output | zstd 3 | Smaller than gzip -6, about 5x faster to compress, 2x faster to unpack |
| When CPU time is the limit | zstd 1 | As fast as single-threaded LZ4 here, with 28% smaller output |
| Many small, similar responses (pages, API replies) | zstd with a dictionary trained on your own data | 32% smaller per page than Brotli 11 on pages it had never seen |
| Release archives | zstd 22 with --long=27, or xz -9 for the smallest file | On code and text xz -9 is about 2% smaller, on mixed binaries 6.7% smaller; zstd unpacks 3.8x to 5.1x faster |
| Photos, video, existing archives | Do not recompress; remove duplicates instead | Unique images did not shrink at all; the only savings came from duplicate files |
How we tested
We built gzip 1.15, Brotli 1.2.1, zstd 1.5.7, XZ Utils 5.8.4 and LZ4 1.11.1 from their official source releases and ran them on a shared cloud server with four virtual CPUs (a DigitalOcean Premium Intel instance). Every tool ran on one thread, with input and output held in memory so the disk did not affect timings. For the three file sets (the Python source tarball, Wikipedia text and the Silesia corpus), each setting got one warm-up run and three timed runs and we report the median (for the single-threaded LZ4 reruns our published file records the median speeds rather than each run’s time); the web test covered six settings (gzip -6 and -9, Brotli 5 and 11, zstd 3 and 19) and measured sizes only. Every decompressed file, in every test, was compared byte for byte with the original. Three follow-up tests ran later on the same server with each tool alone on the machine: threads (one, two and four), a zstd dictionary for single pages, and 400 already-compressed images. Running alone made every tool faster than in the main runs, where four jobs shared the server, so we only compare those results with each other. Some runs shared the machine with other benchmark jobs, each pinned to its own virtual CPU.
Don't miss new tech stories on Google
Add Tech Insider once in the Google app and our stories appear in your news suggestions.
The speed and size map: every setting on one chart
Before getting to individual jobs, it helps to see the whole trade-off at once. The chart below plots all 17 settings we ran on the Python source: further up means a smaller file, further right means faster compression. Each line joins one tool’s levels, so you can see how much size each extra level buys and what it costs in speed.

Three things stand out. First, zstd’s line sits above gzip’s across the whole range gzip covers: zstd 3 compressed at 112 MB/s and still produced a smaller file (3.83 to 1) than gzip -9 managed at 7.9 MB/s (3.74 to 1). Second, gzip’s top levels buy almost nothing. Going from -6 to -9 cut its compression speed from 21.7 MB/s to 7.9 MB/s, nearly two-thirds slower, for a file less than 1% smaller. Third, Brotli and zstd both fall off a cliff at the top. Brotli 9 to 11 raised the ratio from 4.43 to 4.91 while speed dropped from 2.5 MB/s to 0.33 MB/s, and zstd 9 to 19 went from 4.27 to 4.74 while speed dropped from 32 MB/s to 1.25 MB/s.
The top end holds a surprise. On one thread, xz -6 compressed faster than zstd 19 on all three of our file sets (1.5 against 1.25 MB/s on the Python source) and produced a smaller file each time. SumGuy’s independent benchmark reported the same pattern on its own data sets. Zstd’s advantage at that end is unpacking: 363 MB/s against xz’s 79 MB/s on the same file.
Serving a website: Brotli for static files, and test file by file
We fetched 200 Tech Insider article pages from our own server, uncompressed and fully rendered, plus the six CSS and JavaScript files those pages load: 54.2 MB in 206 files. Our pages carry most of their styling and scripts inline, so the HTML is the bulk of what a visitor downloads. We then compressed each file on its own, because a browser receives one compressed response per file.
| Setting | All 206 files | Average article page | vs gzip -6 |
|---|---|---|---|
| Uncompressed | 54.2 MB | 270 KB | |
| gzip -6 (a common server default) | 12.0 MB | 59.9 KB | baseline |
| gzip -9 | 11.9 MB | 59.6 KB | 0.5% smaller |
| Brotli 5 | 10.9 MB | 54.5 KB | 9.0% smaller |
| Brotli 11 | 9.7 MB | 48.4 KB | 19.1% smaller |
| zstd 3 (its default) | 12.3 MB | 61.1 KB | 2.1% larger |
| zstd 19 | 10.6 MB | 52.8 KB | 11.8% smaller |

Brotli’s lead on HTML has a simple cause: the format, defined in RFC 7932, carries a built-in dictionary of common words and markup fragments, which helps on text. Zstd has no built-in dictionary, which is why its default setting came out slightly larger than gzip on our pages. Results depend on your pages, so test your own before switching.
Brotli 11 is far too slow to run on every request; it compressed at about a third of a megabyte per second in our tarball test. It is meant for files you compress once at build or deploy time and serve many times. For responses generated on the fly, Brotli 5 was 9% smaller than gzip -6 and compressed faster than it in our tarball run. Browsers say what they accept, and MDN’s Content-Encoding reference lists gzip, br and zstd among its values, so keep a gzip copy for clients that do not send br. If your front end is built with a bundler, the step that writes Brotli and gzip copies belongs in the build; our Vite vs Webpack comparison covers where each tool fits in that pipeline.
Why archive-style tests flatter web compression
We also compressed the same 206 files as a single tar archive. Brotli 11 then reached a ratio of 23.4 to 1 and zstd 19 reached 21.9 to 1, against 5.6 and 5.1 to 1 file by file. Every page repeats the same header, menus, styles and footer, and in one archive the compressor only has to store that once. Gzip barely changed (4.55 against 4.51 to 1), because it can only look back 32 KB and cannot see from one page to the next. A web server compressing separate responses gets none of that gain, so if a benchmark compresses a folder of web assets as one blob, its web figures are not the savings your visitors will see.
Small pages and the dictionary trick
Every article page on a site repeats the same header, menus, styles and scripts. A compressor working on one page at a time cannot see that, but zstd can be handed a dictionary of the shared material in advance. The zstd manual describes the --train option that builds one from sample files. We trained a dictionary on 100 of our article pages, which produced a 110 KiB (112.6 KB) file, then compressed 100 different pages one at a time with and without it, so the test pages were never part of the training set.

The effect was larger than any change of tool or level. Zstd 3 with the dictionary averaged 39.5 KB per page against 60.0 KB for gzip -6, 34% smaller, and compressing all 100 pages took 0.6 seconds in total. Zstd 19 with the dictionary averaged 32.8 KB, 32% smaller than Brotli 11’s 48.5 KB, and it compressed the 100 pages in 12.8 seconds against Brotli 11’s 60.1 seconds. Unpacking cost the same with or without the dictionary, about 0.3 seconds for all 100 pages.
The catch is that both sides need the dictionary. Measured against Brotli 11, a visitor would have to read about seven of our pages before the 112.6 KB dictionary paid for itself, and that is before compressing the dictionary file itself. Where you control both ends, such as a mobile app talking to your API or servers syncing records with each other, it is a straightforward win today. For browsers, it depends on the standard described next.
What browsers will accept
A server can only send an encoding the browser asks for in its Accept-Encoding header. Gzip works everywhere. Brotli has been supported since Chrome 50, Firefox 44, Safari 11 and Edge 15, according to MDN’s browser compatibility data, so it is safe to offer by default. Zstd is newer: Chrome 123, Firefox 126 and Safari 26.3 decode it, and Safari before macOS 26.3 Tahoe cannot. That makes zstd a bonus for clients that ask for it, never a replacement for Brotli and gzip.
Shared-dictionary compression, which lets a browser reuse an earlier response as the dictionary for the next one, is now a standard: RFC 9842, Compression Dictionary Transport, defines the dcb (Brotli) and dcz (zstd) encodings. Chrome has supported them since version 130, but MDN lists the feature as experimental and not Baseline: Safari does not support it and Firefox has it only in preview. Our dictionary test above shows why the idea is attractive for repetitive pages; for now it is something to watch rather than deploy.
Setting it up on your server
The cheapest win is to compress static files once, when you deploy, and let the web server pick the right copy for each visitor. On nginx, the gzip_static module sends a file’s precompressed .gz copy instead of the original; the nginx documentation notes that it is not built by default and needs the --with-http_gzip_static_module option. For Brotli, Google’s ngx_brotli adds two modules: a static one that serves precompressed .br files through brotli_static, and a filter that compresses on the fly, with its level set by brotli_comp_level (default 6).
# nginx with google/ngx_brotli built as dynamic modules
load_module modules/ngx_http_brotli_filter_module.so;
load_module modules/ngx_http_brotli_static_module.so;
http {
brotli_static on; # serve page.html.br when it exists and the browser accepts br
gzip_static on; # otherwise page.html.gz
brotli on; # responses with no precompressed copy
brotli_comp_level 5; # the per-request level from our web test
gzip on;
gzip_comp_level 6; # fallback for clients without Brotli
}
Apache 2.4 ships mod_brotli. Its BROTLI_COMPRESS output filter compresses responses on the fly, with BrotliCompressionQuality defaulting to 5, the same level our per-request test favoured. The module’s documentation also shows how to serve precompressed .br files with mod_rewrite rules that check the visitor’s Accept-Encoding header and whether the .br file exists. Whichever server you use, keep the uncompressed original next to the compressed copies, so clients that accept neither still get a valid page.
Backups, logs and build output: zstd by default, and even when CPU is tight
For data you write more often than you read, compression speed matters as much as size. On the 109.6 MB Python 3.13.1 source tarball, a mix of C, Python and documentation much like a typical code repository, zstd at its default level beat gzip’s default on size and on both speeds, at the cost of more memory: about 44 MiB to compress against under 3 MiB for gzip.
| Setting | Size ratio | Compress | Decompress |
|---|---|---|---|
| gzip -6 | 3.71 : 1 | 21.7 MB/s | 188 MB/s |
| gzip -9 | 3.74 : 1 | 7.9 MB/s | 229 MB/s |
| zstd 1 | 3.57 : 1 | 257 MB/s | 660 MB/s |
| zstd 3 | 3.83 : 1 | 112 MB/s | 399 MB/s |
| LZ4 1 | 2.57 : 1 | 255 MB/s | 549 MB/s |
Zstd 3 produced slightly smaller output than gzip -6, compressed about five times faster and decompressed about twice as fast. Turning gzip up to -9 bought less than 1% in size for a run almost three times slower, which is rarely worth it. The surprise was LZ4. Its reputation is speed, and its project page quotes compression above 500 MB/s per core, but on one thread with this data the LZ4 command-line tool compressed at 255 MB/s, no faster than zstd -1, while zstd -1’s output was 28% smaller. LZ4’s library is still a fine choice inside software that calls it directly; for a backup script, zstd -1 is the better fast option. Either way the drive may set the pace first: our NVMe vs SATA comparison has the write speeds, and our external SSD vs hard drive comparison shows how slow a USB hard drive is by comparison.
The zstd format is an IETF RFC, and for a tar-based backup script the switch is usually a one-flag change. Multithreading (-T0) makes zstd faster still on large files; we kept every test to one thread so the tools compete on equal terms.
What extra threads buy
Our main tests used one thread so the tools competed on equal terms, but real backup jobs usually run on every core. We reran four settings on the Python source with one and four threads on our four-core server, with each tool alone on the machine.

The slow, heavy settings gained the most. Xz -6 went from 71.0 seconds to 22.0 seconds, 3.2 times faster, at the price of a file 0.6% larger, because the multithreaded file is split into independent blocks; those blocks also unpacked in parallel, cutting decompression from 1.23 to 0.48 seconds. Zstd 19 went from 78.5 to 37.2 seconds with an identical file. LZ4 gained 1.7 times. Zstd 3 barely moved: 0.66 seconds on one thread, 0.46 seconds on two and 0.58 seconds on four. On a file this size the job finishes too quickly for extra threads to help much, and on a shared cloud server the extra cores are not always free. If your backups are large, use -T0 and let zstd decide; if they are small, the thread count hardly matters.
Archives you publish once: xz and high-level zstd
Source releases, firmware images and installers are compressed once and unpacked by everyone who downloads them, so size and unpacking speed matter and compression time mostly does not.
| Setting | Size ratio | Decompress | Memory to compress | Memory to decompress |
|---|---|---|---|---|
| xz -6 (xz default) | 4.85 : 1 | 79 MB/s | 95 MiB | 10 MiB |
| xz -9 | 4.98 : 1 | 80 MB/s | 675 MiB | 66 MiB |
| zstd 19 | 4.74 : 1 | 363 MB/s | 198 MiB | 12 MiB |
zstd 22 with --long=27 | 4.88 : 1 | 350 MB/s | 840 MiB | 109 MiB |
| Brotli 11 | 4.91 : 1 | 214 MB/s | 215 MiB | 20 MiB |
Xz -9 still produced the smallest file, but only by about 2% against zstd 22 with a long match window, and zstd unpacked the result more than four times faster. For a large download that is unpacked on many machines, that speed difference is felt by every user, while the 2% is felt mainly by the server bill. A --long=27 file unpacks with a plain zstd -d; if you go above 27, the person unpacking must pass the same --long value or a larger memory limit, so document it next to the download.
Does the kind of file change the answer?
The Python tarball is mostly source code, which compresses unusually well. To see whether our picks survive other data, we ran the same 17 settings on two standard test sets: enwik8, the first 100 million bytes of a 2006 English Wikipedia dump, published with Matt Mahoney’s Large Text Compression Benchmark and also used for the Hutter Prize; and the Silesia corpus, 212 MB in 12 files that mix text, executables, a database, XML files and medical images. Same builds, same machine, same single-thread method.
| Setting | Python source | Wikipedia text (enwik8) | Mixed files (Silesia) |
|---|---|---|---|
| LZ4 1 | 2.57 : 1 | 1.75 : 1 | 2.11 : 1 |
| gzip -6 | 3.71 : 1 | 2.74 : 1 | 3.11 : 1 |
| zstd 3 | 3.83 : 1 | 2.82 : 1 | 3.20 : 1 |
| zstd 19 | 4.74 : 1 | 3.71 : 1 | 4.01 : 1 |
zstd 22 with --long=27 | 4.88 : 1 | 3.96 : 1 | 4.06 : 1 |
| Brotli 11 | 4.91 : 1 | 3.89 : 1 | 4.26 : 1 |
| xz -6 | 4.85 : 1 | 3.79 : 1 | 4.31 : 1 |
| xz -9 | 4.98 : 1 | 4.02 : 1 | 4.35 : 1 |
The everyday picks held on all three. Zstd 3 beat gzip -6 on size every time and compressed 5.2 times faster on the source code, 5.7 times faster on Wikipedia text and 7.6 times faster on the mixed set, while unpacking 1.7 to 2.1 times faster. Zstd 1 stayed level with single-threaded LZ4 on speed and produced 27% to 29% smaller files. LZ4 does its worst on plain prose: on Wikipedia text its fastest setting shrank the file by less than half, to 57% of its original size. LZ4 still unpacked faster than zstd 1 on Wikipedia text (418 against 341 MB/s) and on the mixed set (517 against 440 MB/s), though not on the source code.
The release-archive advice is where the data moved us. On source code and on Wikipedia text, zstd 22 with a long window came within about 2% of xz -9. On the mixed Silesia set the long window barely helped, making the file 1.1% smaller than zstd 19 against 2.9% on the source code and 6.2% on the text, and xz -9 produced a 6.7% smaller file. Even the default xz -6 and Brotli 11 beat zstd’s best setting there. Zstd still unpacked that archive 5.1 times faster than xz -9, so the trade-off is the same one as before, but for a release made of mixed binaries, xz earns its place if file size is what you are optimizing for.
Photos and video: compressing them again is wasted work
Formats such as WebP, JPEG and MP4 are already compressed, so a general-purpose compressor should find almost nothing left to remove. We checked with a sample of 400 full-size images published on Tech Insider in October 2026, 54.2 MB in one tar file: 355 WebP, 40 JPEG and 5 PNG.
| Setting | Space saved | Compression speed |
|---|---|---|
| LZ4 1 | 1.0% | 459 MB/s |
| gzip -6 | 1.3% | 26 MB/s |
| xz -6 | 10.9% | 1.8 MB/s |
| zstd 3 | 11.1% | 192 MB/s |
| Brotli 5 | 11.3% | 98 MB/s |
| zstd 19 | 11.3% | 3.8 MB/s |
An 11% saving looked too good, so we took the set apart. Forty-two of the 355 WebP files were exact duplicates of other files in the set, the same image uploaded more than once. Zstd, Brotli and xz look far enough back to spot a repeated file and store it once; gzip and LZ4 look back only a few dozen kilobytes, so they could not. With the duplicates removed, zstd 3 made the 313 unique WebP files 799 bytes larger than they started. For photos and video the useful step is finding duplicates, not compressing; in our sample, 12% of the WebP files were stored twice.
What unpacking costs in memory
Benchmarks rarely report decompression memory, but it decides what a router, a small virtual server or an embedded board can open. In our runs gzip needed about 2 MiB to decompress, xz -6 about 10 MiB, zstd 19 about 12 MiB and Brotli about 20 MiB. The settings that squeeze hardest raise that floor: xz -9 output needed 66 MiB to unpack and zstd 22 with --long=27 needed 109 MiB. If the machine that opens your archive has a few hundred megabytes of RAM shared with everything else, pick the setting with that in mind, not just the smallest file.
Those figures barely moved with the data. Across the Python source, Wikipedia text and the Silesia corpus, xz -9 needed 66 MiB to decompress every time, zstd 19 needed 12 MiB, Brotli 19 to 20 MiB and gzip 2 MiB. Zstd 22 with the long window varied most, from 99 to 132 MiB. LZ4 was the odd one out: its command-line tool used about 31 to 33 MiB to decompress, far more than gzip or zstd, so on very small devices the “lightweight” choice is not the one with the smallest memory footprint. Compressing costs far more memory than unpacking at the top settings: Brotli 11 used 203 to 277 MiB, xz -9 675 MiB and zstd 22 with --long=27 829 to 970 MiB.
Patch your decompressors too
Decompressors read untrusted input all day, which makes them attack surface. The XZ Utils project page lists two recent decoder bugs: an invalid memory write when a decoder is reinitialized after an allocation failure, in 5.8.3 and older, and CVE-2026-34743, a buffer overflow in lzma_index_append() in 5.8.2 and older, which the project says needs conditions that likely do not exist in real applications. The 5.8.4 release we tested is newer than both. The same page keeps the record of the 2024 backdoor, CVE-2024-3094. Microsoft’s Security Update Guide lists CVE-2026-111497, a Google-assigned buffer overflow in the Brotli decoder rated critical, because .NET ships the Brotli library; Microsoft notes that .NET only decompresses Brotli when an application opts in. Neither is a reason to avoid a format; they are a reason to take compression libraries from your operating system’s updates and to rebuild statically linked tools when a decoder fix lands.
The commands we used
These use the compression levels we tested, on the versions listed above. Our main benchmark ran on one thread; the -T0 flag below uses every core, as in our thread test.
# Static web files: keep the original, write .br and .gz next to it
brotli -q 11 -k page.html
gzip -9 -k page.html
# Backups and logs: zstd default level, all cores
zstd -3 -T0 backup.tar
# Fast option when CPU time is the limit
zstd -1 -T0 data.tar
# A release archive with a long match window, and how to unpack it
zstd --ultra -22 --long=27 -T0 release.tar
zstd -d release.tar.zst
# Smallest file when unpacking speed and memory do not matter
xz -9 -T1 -k release.tar
# A zstd backup straight from tar
tar -I 'zstd -3 -T0' -cf backup.tar.zst /data
# Train a dictionary on sample pages, then use it on both ends
zstd --train samples/*.html -o site.dict
zstd -19 -D site.dict page.html
zstd -d -D site.dict page.html.zst -o page.html
Where your numbers will differ
Absolute speeds depend on the processor, and a shared cloud machine adds some noise; the comparisons between tools on the same data are what carry over to your hardware. Pages with less inline code than ours will compress differently, so run the web test on your own HTML. Text and code compress well, while photos, video and files that are already compressed do not shrink unless the set contains duplicates. The full results are available to download: Python source tarball, all 17 settings, LZ4 run single-threaded (CSV), 200 web pages and their assets, file by file and as one archive (CSV) , all 17 settings on the Python source, Wikipedia text and the Silesia corpus (CSV), one, two and four threads (CSV), the dictionary test, page by page totals (CSV) and 400 already-compressed images (CSV).




