Content distribution network

A content push backend that stays fast under traffic bursts

A content distribution network was dropping requests when traffic surged, so we rebuilt the hot path in Go with caching and a persistent queue.

The situation

The client ran a network that pushed visual content to thousands of remote displays. Requests had to be matched, logged and dispatched within a tight latency budget.

When traffic surged, the system fell over in familiar ways. The database connection pool saturated and requests timed out. Garbage collection pauses froze workers. During peak hours some requests were lost, which broke the client's own commitments.

Adding servers would not have fixed the cause.

What we did

  1. 01

    Measured where time went

    We load tested the existing path and found where latency built up: connection pool limits, blocking calls and pauses in the synchronous workers.

  2. 02

    Rebuilt the hot path in Go

    Request handling moved to concurrent Go pipelines using goroutines. Python and Django handled the supporting pipelines.

  3. 03

    Added a Redis caching tier

    Frequently read data was served from cache, which kept pressure off the database and the connection pool.

  4. 04

    Buffered with a persistent queue

    A persistent queue absorbed bursts and gave failover routing something to fall back on, so surges were held instead of dropped.

  5. 05

    Kept the displays in step

    We added client-side caching so remote displays stayed in sync across many nodes, even when a connection was slow.

What changed

  • The system held steady throughput under sustained load.
  • Latency stayed inside the agreed budget instead of spiking at peak.
  • Traffic bursts were queued, not lost, so fewer requests dropped.
  • The database stopped being the first thing to saturate.
  • 2,000+ sustained QPS with sub-40ms P99 on a Go and Python backend

Stack

  • Go
  • Python
  • Django
  • Redis
  • AWS
  • Persistent queue