Intermediate·Concept·2 min read

When should I use pagination, streaming, compression or a CDN?

Practice this question

Definition:

Pagination, streaming, compression and CDNs reduce different costs of moving data. Pagination returns fewer records, streaming avoids buffering the full payload, compression sends fewer bytes, and a CDN shortens the route for reusable content. Choosing the right technique requires knowing whether the problem is volume, memory, bandwidth or distance.

Key points:

  • Pagination limits records; streaming limits memory used for large data transfers.

  • Compression reduces suitable payload sizes but costs CPU.

  • A CDN caches suitable content near users; private data needs careful cache rules.

  • Already compressed formats may gain little from more compression, while CPU cost can increase under load.

Interview point:

  • A stream can fix memory pressure without reducing total database work; describe which cost your change actually addresses.
Adapted from 08_PERFORMANCE_SECURITY.md · “When should I use pagination, streaming, compression or a CDN?”. Code examples are study fragments. Difficulty and core labels are editorial estimates; version-specific behavior should be checked against your project.