Yes. The ApsaraMQ for Kafka broker supports sending and receiving compressed data. To enable compression, set compression-related parameters on your ApsaraMQ for Kafka client.
Supported compression formats
ApsaraMQ for Kafka supports the following compression formats:
| Format | Compression ratio | CPU overhead |
|---|---|---|
| LZ4 | Moderate | Low |
| Snappy | Moderate | Low |
| GZIP | High | High |
Use LZ4 or Snappy for most workloads. GZIP delivers higher compression ratios but consumes significantly more CPU. Reserve GZIP for scenarios where storage or bandwidth savings outweigh the CPU cost, such as log ingestion.
When compression makes sense
CPU resources are generally more expensive than network and storage resources. Enable compression only when the bandwidth or storage savings justify the additional CPU cost -- typically in high-volume scenarios with highly compressible data such as log pipelines.
On average, compression adds more than 20% CPU overhead. Test the actual overhead in your environment before you enable compression in production.