AlgoViz

CDN operations

medium 30 min

Running a CDN day by day: what to measure, when to wake somebody, how to keep attackers away, how to make it faster and cheaper, and how to find out why a user got a slow, stale or broken answer.

See it run

Read a dashboard, follow a request through the protection, find a stale copy, prepare for a peak and change a rule safely.

Operations

Reading the dashboard

Six points in time for four numbers. Example values.

Step 1 of 5

Hit ratio

123456
hit ratio89%91%92%93%94%94.5%
p95 ms
saved TB/day
5xx rate

94.5% of 95%

94.5%, rising, just below the target of 95%. Misses fell from 11% to 5.5%: half the origin load.

Step 1: Hit ratio

hit_ratio = hits / requests          # target 95%p95 = percentile(latency_ms, 95)     # target 50 mssaved = bytes_from_cache_per_day     # target 2.0 TBerrors = count_5xx / requests        # target 0.1%
When
Every day
You learn
Trends
Targets
95%, 50 ms, 2 TB, 0.1%

Translate the ratio into origin load before you relax.

In the real world

The same cdn operations doing real jobs. Pick one and step through it.

Eight locations.

Step 1 of 3

All healthy

locationstatetraffic
Tokyohealthy100%
Londonhealthy100%
New Yorkhealthy100%
Sydneyhealthy100%
Frankfurthealthy100%
Singaporehealthy100%
Sao Paulohealthy100%
Mumbaihealthy100%

8 of 8 healthy

Every check from outside succeeds.

Step 1: All healthy

Common mistakes

The bugs interviewers watch for, with the fix beside each.

  • Alerting on the hit ratio alone

    major

    95% to 90% looks small and doubles the origin's load.

    Wrong
    alert_if(hit_ratio < 0.80)
    Right
    alert_if(origin_rps > 0.6 * origin_capacity)warn_if(hit_ratio < 0.85)
  • Blocking by user agent

    major

    Attackers choose any name. Real tools and crawlers are lost.

    Wrong
    if "bot" in user_agent.lower(): return 403
    Right
    if claims_crawler(user_agent) and not verified_by_dns(ip): challenge()
  • Global rule at once

    critical

    A bad rule stops every user in every place within seconds.

    Wrong
    rule.enable(percent=100)
    Right
    rule.mode = "log"      # then 1%, 25%, 100%
  • Origin reachable around the CDN

    critical

    Every protection at the edge can be skipped.

    Wrong
    firewall.allow("0.0.0.0/0", port=443)
    Right
    require_client_certificate(ca="cdn")

Interview tips

  • How to explain it

    • Wardens of mountain huts.
    • Flags, a soup board, a gate, porters.
    • A label on each bowl.
  • Memory trick: MOST

    • Monitoring, Optimization.
    • Security.
    • Troubleshooting.
  • Targets to start with

    • Hits above 90% for static files.
    • p95 below 100 ms, 5xx below 0.1%.
    • Origin below 20% of requests.
  • Debug order

    • Hit or miss?
    • Age and ETag?
    • Which place, every place?