
Bytes on a Diet, Part 1: Trim the Wire
Amazon DocumentDB 8.0.1's new Snappy network compression: one connection string parameter, roughly 2× sustained write throughput, zero application code changes
Series: Bytes on a Diet (1 article)
- 1Bytes on a Diet, Part 1: Trim the Wire This article
Bytes on a Diet, Part 1: Trim the Wire
Amazon DocumentDB has been quietly building out compression for a while. LZ4 for storage landed on 5.0 in July 2024 — opt-in, per collection. Customers turned it on for their existing clusters, and every newly written or updated document was compressed from that point forward. Useful for anyone looking to optimise their storage spend. Then in November 2025, Zstd with dictionary compression arrived in 8.0 — every new write compressed by default, and clusters quietly started fitting more data in the same storage footprint. And in 8.0.1, the newest piece landed: compression with Snappy on the wire itself.
Two kinds of compression, one series
This is Part 1 of a two-part series on compression in Amazon DocumentDB. Part 1 covers network compression; Part 2 covers storage compression.
There are two independent compression layers — storage and network — using different algorithms at different points in the data path. You can enable one, both, or neither. The quick map:
| Storage compression | Network compression |
|---|---|---|
What it compresses | Stored documents | Data on the wire (application ↔ cluster) |
Algorithms | Zstd (8.0 default), LZ4 (5.0+) | Snappy |
Availability | Amazon DocumentDB 5.0+ (LZ4), 8.0+ (Zstd) | Amazon DocumentDB 8.0.1+ |
Scope | Per collection | Per connection (connection string flag) |
Default on 8.0 | Zstd ON | OFF (opt-in) |
Setting type | Static (once enabled on a collection, it stays) | Dynamic (toggle per connection anytime) |
That latest one — network compression — is what I want to start with. I keep seeing the same pattern from customers running high-throughput workloads on Amazon DocumentDB: CPU has headroom, storage IOPS aren't maxed, and yet write throughput plateaus. They look at every metric on the cluster and everything says "we can do more." The bottleneck they aren't looking at is the wire.
One connection string parameter fixes it. In a TPC-C benchmark on two otherwise-identical 8.0.1 clusters, it roughly doubled sustained write throughput and finished the workload half an hour faster. Here's what it does, how to turn it on, and the one operational detail worth knowing before you flip it.
What network compression does
Network compression arrived in Amazon DocumentDB 8.0.1. Every insert, every query result, every bulk write between your application and the cluster gets compressed with Snappy before it goes on the wire. Less data moving means higher throughput and faster workload completion — the cluster spends less time deserialising bytes and more time doing actual work.
Snappy is deliberately chosen for the wire because it prioritises speed over ratio — it doesn't compress as tightly as Zstd, but it's fast enough that compression itself never becomes the bottleneck.
It works on your existing cluster. No migration, no new cluster, no data movement. If you're already on 8.0, a minor version upgrade gets you to 8.0.1. If you're on 5.0 or earlier, see the major version upgrade guide , or upgrading with minimal downtime .
How to turn it on
Add
compressors=snappy to your connection string:mongodb://cluster-endpoint:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&retryWrites=false&compressors=snappyOr, using PyMongo:
from pymongo import MongoClient
client = MongoClient( "mongodb://cluster-endpoint:27017/", tls=True, tlsCAFile="global-bundle.pem", replicaSet="rs0", retryWrites=False, compressors="snappy")One operational detail worth knowing. Thecompressors=snappyparameter is negotiated when a connection is first established, so it applies to new connections only. Existing connections in your driver's pool keep flowing uncompressed until they cycle. Nothing else to change — queries, drivers, indexes, and application code all stay the same.
Note: A missing client-side compression dependency won't break your connection — the driver falls back to uncompressed messages. No error is raised, but you may see a log warning about the missing dependency. To confirm compression is actually active, verify the negotiated compressor as described in Verify compression .
Network compression in action
To measure the impact, I ran a TPC-C benchmark against two Amazon DocumentDB 8.0.1 clusters. Identical instance types, identical workload, identical client. The only difference: one cluster had
compressors=snappy in the connection string, the other didn't.Test configuration
| |
|---|---|
Workload | TPC-C via tpcc.py |
Command | python3 tpcc.py mongodb --config mongodb.config.docdbtpc --clients 30 --warehouses 250 --no-execute |
Amazon DocumentDB instance (primary) | db.r8g.2xlarge (both clusters) |
TPC-C client instance | c5.4xlarge |
Cluster A | docdb-81 — network compression ON (Snappy) |
Cluster B | docdb-802 — network compression OFF |
Results
Metric | Compression ON | Compression OFF |
|---|---|---|
NetworkReceiveThroughput (peak) | ~4–5 MB/s | ~8.8 MB/s |
WriteIOPS (sustained) | ~65–77K | ~35–40K |
CPUUtilization (peak) | ~35–38% | ~15–20% |
Time to complete workload | ~60 min | ~90 min |
The compressed cluster received roughly half the bytes from the client. With less data to deserialise per request, it sustained nearly double the WriteIOPS and finished the entire workload about 30 minutes faster. CPU ran modestly higher — that's Snappy doing compression and decompression work — but the trade-off is favourable: a small CPU cost for a large throughput gain and a materially shorter workload runtime.
The CloudWatch metrics tell the story per axis. In every chart, docdb-81 (compression ON) is shown in blue and docdb-802 (compression OFF) in orange.
Fewer bytes on the wire

NetworkReceiveThroughput: the compressed cluster receives roughly half the bytes for the same workload.
This is the compression happening. The compressed cluster peaks around 4-5 MB/s of received traffic; the uncompressed cluster peaks around 8.8 MB/s. Same client, same TPC-C load, roughly half the bytes on the wire.
More work done per second

WriteIOPS: the compressed cluster sustains roughly double the write throughput.
Fewer bytes to deserialise per request means the cluster spends more of its time on actual database work. WriteIOPS sustains ~65-77K on the compressed cluster versus ~35-40K without. The wire was the bottleneck; unblocking it lets the cluster do close to twice as much work with the same hardware.
The CPU cost, honestly

CPUUtilization: the compressed cluster runs modestly hotter — Snappy earning its keep.
Compression isn't free. The compressed cluster runs at ~35-38% CPU versus ~15-20% for the uncompressed one — Snappy doing compression and decompression on every message. Well within capacity, and a favourable trade for the throughput it buys you.
Faster to done

Documents inserted over time: the compressed cluster finishes the full load about 30 minutes sooner.
Same workload, roughly 60 minutes with compression versus 90 minutes without. Half an hour saved per run. On a load you replay daily — a nightly ingest, a batch job, a re-index — that's meaningful compute time and cluster hours you would otherwise pay for.
When this matters most
Network compression helps most when the wire is your bottleneck — large documents, high insert rates, bulk loads, ingestion pipelines. If your workload is mostly small reads served from the buffer cache, the gains will be smaller because there's less data crossing the wire in the first place.
Either way, the cost of enabling it is effectively zero: one connection string parameter, one connection cycle, no application code change. If you're on 8.0.1, there's very little reason not to turn it on and see what your own cluster does.
Coming up in Part 2
Part 2 covers storage compression — The Diet You Didn't Know Your DocumentDB Cluster Is On. On Amazon DocumentDB 8.0, Zstd with dictionary compression is already on by default, and most clusters are quietly fitting roughly 5× more data in the same storage footprint without anyone having configured it. I'll show how to check what your cluster is already saving, when to reach for LZ4 instead of Zstd, and how to manage compression per collection.
References
If you've made it this far, come join the NoSQL Launchpad in Builder Center. That's where the AWS NoSQL specialists hang out, share what they've learnt, and post things like this.
#amazon-documentdb #compression #performance #nosql
Series: Bytes on a Diet (1 article)
- 1Bytes on a Diet, Part 1: Trim the Wire This article
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article