Less bytes more CPU
Compression shrinks data so it travels and stores cheaper, but encoding and decoding spend CPU. Whether it pays depends on whether the bottleneck is the network or the processor.
When it helps
- Slow or costly links benefit because fewer bytes cross the wire.
- Repetitive data like text and logs compresses well.
- Cold storage saves money holding fewer bytes.
When it hurts
- Already compressed data such as images or video gains little and wastes CPU.
- Tiny payloads can grow because of header overhead.
- CPU bound services may slow down if they are already saturated.
Picking a codec
- Fast codecs give modest ratios with little CPU for hot paths.
- Strong codecs give high ratios at more CPU for archives and bulk transfer.
Measure end to end
Test the real workload, since the win is the time saved on the wire minus the time spent compressing and decompressing. On a fast network a heavy codec can be slower overall.
Key idea
Compression trades CPU for smaller data, so pick a codec by whether the network or the CPU is the true bottleneck and verify end to end.