Library / Blogs

HTTP/3: the past, the present, and the future

A history of HTTP versions and what HTTP/3 over QUIC changes.

IntermediateHTTP and QUICCDN

By Cloudflare · Cloudflare · Added 2026-10-12

Open original source

All content belongs to Cloudflare. We only link to it and give credit. Report a problem

Learn this article

About 37 min left. Your work is saved as you go.

What you are about to study

Cloudflare wrote this to explain how they thought about a problem. You should know the basics: caching, queues and replication.

Ideas you will meet

HTTP and QUIC
HTTP versions, QUIC, caching headers and web performance.
CDN
Serve content from edge locations close to users.

What we already know about this

Our own lessons on these ideas. Read them here before you start, so it makes sense.

  • System Design Foundations · 11 minNetworking, APIs and CDNsWhat happens between a click and your server: DNS, HTTP, API styles, and how a CDN moves content closer to users.Read here

    The journey of a request

    Before your code runs, a lot happens. When a browser loads https://shop.example.com:

    Figure SDA-FND-09-1 · Request journey: DNS, CDN, origin · © forcsguy.com

    1. DNS turns the name into an IP address. Answers are cached at several levels for a time given by the record's TTL, so changes spread gradually.
    2. A connection is opened (TCP) and secured (TLS). Each step costs round trips, so long distances hurt.
    3. HTTP carries the request and response.

    Latency is mostly physics: a round trip across an ocean costs over 100 ms no matter how fast your code is. The only fixes are fewer round trips and moving data closer to the user.

    Optical fiber connections in network equipment: long distances are carried as light in glass fibersImage: Syced · CC0 · Source · Wikimedia Commons: Fujikura optic fiber at Science Museum

    Name lookup is a short chain of questions, each answered by a more specific server:

    Figure SDA-FND-09-2 · How a name becomes an address · © forcsguy.com

    A nineteenth-century map of the first transatlantic telegraph cable; today's internet still crosses oceans on undersea cables, which is why distance costs latencyImage: Howe's Adventures & Achievements of Americans · Public domain · Source · Wikimedia Commons: Transatlantic submarine cable map

    CDNs

    A content delivery network is a worldwide set of servers (edges) that keep copies of your content close to users.

    • Great for static files: images, video, scripts, stylesheets, and often whole pages that rarely change.
    • Cuts latency, absorbs traffic spikes and shields your origin from load.
    • Controlled by cache headers (Cache-Control: max-age=...) and purge APIs when content changes.
    • Use a versioned file name (app.3f9a.js) so you can cache for a year and still ship updates instantly.

    Figure SDA-FND-09-3 · Content delivery in tiers · © forcsguy.com

    Before: everyone goes to the origin

    After: a CDN serves copies near users

    What changed

    • Users get files from a nearby location
    • The origin handles far fewer requests
    • Changed files need invalidation or versioned names

    Choosing an API style

    StyleStrengthWatch out for
    REST over HTTP/JSONSimple, cacheable, universalOver-fetching, many round trips for complex screens
    GraphQLClient asks for exactly the fields it needsQuery cost control, caching is harder
    gRPCFast binary protocol, strong contractsNeeds tooling, awkward in browsers
    SOAPXML messages with a formal contract (WSDL) and built-in standards for security and transactions, still common in banks and older enterprise systemsVerbose, heavier tooling, rarely chosen for new public APIs
    WebSockets / SSEServer can push live updatesLong-lived connections need extra capacity and care

    A good default is REST for public APIs, gRPC between internal services if you need speed, and WebSockets only where live push is truly needed.

    Designing good APIs

    • Version them so old clients keep working.
    • Paginate list endpoints (cursor-based pagination stays stable as data changes).
    • Make writes idempotent with idempotency keys, so a retry does not double-charge.
    • Return clear errors with correct status codes.
    • Authenticate and rate limit at the edge, often in an API gateway that also handles routing, logging and TLS.

    Figure SDA-FND-09-4 · API gateway in front of services · © forcsguy.com

    More on this site

    Open this lesson with its quiz and exercise

  • Classic System Designs · 13 minDesign a video streaming serviceUpload, process and stream video to millions: transcoding pipelines, adaptive bitrate and using a CDN without going bankrupt.Read here

    The problem

    A video streaming service lets users upload videos and lets many others watch them smoothly on any device and connection.

    Requirements

    • Upload large files reliably.
    • Playback starts quickly and does not buffer.
    • Works on phones, TVs and browsers, on fast and slow networks.
    • Huge scale, with traffic dominated by viewing, not uploading.
    • Keep cost under control.

    Estimates that shape the design

    • Video files are big: a few GB uploaded, then several versions stored.
    • Views outnumber uploads by orders of magnitude, and bandwidth is the main bill.

    High-level design

    Two separate flows: upload and process, and stream.

    Figure SDA-CSD-10-1 · Upload-and-process and streaming flows · © forcsguy.com

    Upload

    • The client asks the API for an upload URL and sends the file directly to object storage, in chunks that can resume after a network drop. Your application servers never carry the video bytes.
    • When the upload finishes, storage emits an event that starts processing.

    Processing pipeline

    Raw video cannot be streamed to everyone. The pipeline:

    1. Splits the video into short segments, so they can be processed in parallel.
    2. Transcodes each into several resolutions and bitrates (for example 240p to 4K) and several formats and codecs.
    3. Creates thumbnails, subtitles, and sometimes watermarks.
    4. Runs checks: content moderation, copyright matching, virus scanning.
    5. Writes a manifest listing the available versions.
    6. Updates the metadata (title, status) so the video becomes visible.

    Model it as a graph of tasks run by a workflow engine over a queue and a pool of workers, so steps parallelise, retry independently and scale with load.

    Figure SDA-CSD-10-2 · Transcoding task graph · © forcsguy.com

    Inside the transcoding pipeline

    Transcoding is heavy and varies by creator (some want watermarks, some supply thumbnails, some upload very high resolution). So define the work as a task graph (a DAG): the original is split into video, audio and metadata; the video stage fans out into encodings at several resolutions and bitrates, a thumbnail and optionally a watermark; the audio stage encodes separately; a final stage merges. Independent branches run in parallel.

    The parts that make it run:

    • Pre-processor splits the video into short independently playable chunks (aligned to groups of pictures), builds the graph from configuration, and keeps the chunks in temporary storage so a failed step can retry without starting over.
    • Graph scheduler cuts the graph into stages and puts the tasks on a queue.
    • Resource manager keeps a priority queue of tasks, a priority queue of worker availability and a list of what is running, and pairs the most important task with the best-suited worker.
    • Workers run specific tasks; temporary storage holds metadata in memory and media in blob storage and is cleaned when the job ends.

    Two vocabulary points: a container (.mp4, .mov) is the wrapper holding video, audio and metadata; a codec (H.264, VP9, HEVC) compresses the content. Raw footage can be hundreds of GB per hour, which is the first reason to transcode; the others are device compatibility and adapting quality to bandwidth.

    Cloud services instead of building everything

    Figure SDA-CSD-10-3 · Two paths: video and everything else · © forcsguy.com

    Figure SDA-CSD-10-4 · Upload flow with completion events · © forcsguy.com

    Figure SDA-CSD-10-5 · Metadata is updated in parallel with the upload · © forcsguy.com

    Streaming

    • The player downloads the manifest, then fetches small segments over plain HTTP (the HLS and MPEG-DASH formats work this way).
    • Adaptive bitrate: the player measures its throughput and switches between quality levels segment by segment, so playback adapts to the connection instead of stopping.
    • Segments are static files, ideal for CDN caching.

    Figure SDA-CSD-10-6 · One video, many encodings · © forcsguy.com

    Figure SDA-CSD-10-7 · Popular videos from the CDN, the rest from storage servers · © forcsguy.com

    The CDN and cost

    CDN traffic is expensive. Practical tactics:

    • Serve popular videos from edge caches; keep the long tail only at the origin or in a regional cache.
    • Pre-position new releases that you expect to be popular.
    • Choose bitrates carefully, and use efficient codecs for popular content (extra encoding cost is repaid by lower bandwidth).
    • Large services run their own cache servers inside ISPs to cut transit cost.

    Before: serve from the origin

    After: serve from a CDN

    What changed

    • Viewers stream from a nearby edge, so less buffering
    • The origin handles only cache misses
    • Bandwidth cost falls because edges absorb the traffic

    Metadata and other parts

    • A database for video metadata, ownership, comments and counts, with caches for the hot reads.
    • Search and recommendations as separate services fed by events.
    • View counts are written to a queue and aggregated, not updated row by row on every view.
    • Security: signed URLs for private videos, and DRM for premium content.

    Speed, safety and cost, in detail

    • Parallel and resumable uploads: the client cuts the file into chunks and uploads them independently, so a drop resumes at the last chunk. Put upload points near users (a CDN works as an upload edge).
    • Loose coupling: a queue between download, encode and publish steps lets each stage work as soon as items arrive instead of waiting for the previous stage to finish a whole file.
    • Pre-signed upload URLs: the API issues a short-lived address that authorises one upload to one location, so clients never hold storage credentials.
    • Protecting content: DRM, encrypted streams with an authorisation check at playback, and visible watermarks.
    • Cost: a rough sum shows CDN delivery alone could cost on the order of a hundred thousand dollars a day at this scale, and views follow a long tail. So serve only the popular videos from the CDN, serve the rest from your own storage servers, keep fewer encoded versions of rarely watched videos (encode short ones on demand), keep regional favourites in their region, and at very large scale partner with internet providers or run your own delivery network. Always check your own viewing data first.

    Errors. Separate recoverable errors (a chunk fails to encode: retry a few times) from non-recoverable ones (malformed file: stop the job and return a clear error). A playbook per component: retry uploads and encodes; if an old client cannot chunk, chunk on the server; regenerate a graph or reschedule a task if the pre-processor or scheduler fails; use replicas for queues, caches and databases; promote a replica if a primary database fails.

    Live streaming differs in needing lower latency (a different protocol), less parallelism (chunks are small and processed as they arrive) and error handling that cannot afford long retries. Takedowns need both upload-time checks and user flagging.

    Figure SDA-CSD-10-8 · Chunked, resumable and regional uploads · © forcsguy.com

    Figure SDA-CSD-10-9 · Pre-signed upload URL · © forcsguy.com

    Failure handling

    Every processing task is idempotent and tracked, so a failed or retried segment does not corrupt the output. Failures go to a dead-letter queue and set a visible error status. Use multiple regions for storage and CDN origins so viewing survives a regional outage.

    Worked numbers: why a CDN is not optional

    Suppose 5 million viewers are watching at the same time, each at an average of 3 Mbit/s.

    • Egress: 5,000,000 x 3 Mbit/s = 15 Tbit/s. No single data centre network, and no sensible origin, can send that. Video is served from edge caches close to viewers; the origin only sends each popular segment to each edge once.
    • Why caching works so well: video segments are the same files for everyone watching, and demand is highly skewed. A popular show may be 90%+ cache hits at the edge, so the origin sees a small fraction of the traffic.
    • Upload side: if 1 million videos are uploaded a day at an average of 300 MB, that is 300 TB a day of originals, before the several encoded versions of each (often 5 to 8 renditions, which together can take as much space as the original or more). The long tail of rarely watched videos is the main storage cost, which is why some systems encode extra renditions only when a video becomes popular.

    Figure SDA-CSD-10-10 · Fast transcoding by splitting a video into segments · © forcsguy.com

    How the player picks the quality

    Streaming uses adaptive bitrate (ABR): the video exists in several renditions (for example 240p to 1080p), each cut into the same short segments, and the player decides per segment which one to request.

    1. The player downloads the playlist (manifest) listing the renditions and segments.
    2. It starts with a conservative rendition so playback begins quickly.
    3. For each segment it measures how fast the download went and how full its buffer is.
    4. If the buffer is healthy and the network fast, it steps up a rendition; if the buffer is draining, it steps down before the video stalls.

    Because every rendition has identical segment boundaries, switching is seamless. Viewers see a slightly softer picture instead of a spinning wheel.

    Figure SDA-CSD-10-11 · The player adapts to the network segment by segment · © forcsguy.com

    Mistakes people make

    • Encoding every rendition for every upload. Most videos are barely watched. Encode a base set first and add more when a video proves popular.
    • Serving from the origin. Without a CDN the origin saturates and far-away viewers buffer.
    • Cold caches on a launch. A new popular release hits empty edges. Pre-warm the CDN for expected hits.
    • Uploads that cannot resume. Large files over mobile networks fail often; use chunked, resumable uploads.
    • Forgetting access control. Public segment URLs are easily shared. Use signed, expiring URLs, and DRM where licences require it.
    • Ignoring start-up time. Viewers leave if playback takes more than a couple of seconds. Short first segments, a good first rendition and a nearby edge matter more than peak quality.

    Try it yourself

    Open the System Builder's viral link challenge to see how much traffic a CDN takes off your servers, and the WebRTC lesson for when low-latency live video needs a different approach than segment-based streaming.

    More on this site

    Open this lesson with its quiz and exercise

  • Classic System Designs · 12 minDesign a rate limiterCap how often a client can call an API: the common algorithms, where to put the limiter and how to make it work across many servers.Read here

    The problem

    A rate limiter restricts how many requests a client may make in a period. It protects a service from abuse, accidental floods and runaway scripts, keeps costs predictable and shares capacity fairly.

    Requirements

    • Limit by user, API key or IP, with different limits per rule or plan.
    • Add very little latency to each request.
    • Work across many servers, not just one.
    • Tell rejected clients clearly what happened.
    • If the limiter itself fails, the API should not go down with it.

    Heavy traffic on a road: without limits, demand beyond capacity makes everyone slowerImage: Digitura · CC0 · Source · Wikimedia Commons: Gulf, traffic jam 1970s

    Where to put it

    Figure SDA-CSD-01-1 · Rate limiter in front of the service · © forcsguy.com

    The usual home is the API gateway or a middleware layer, because it sees every request early and rejects cheaply. Building it into each service duplicates effort, and a client-side limiter cannot be trusted.

    Here is the same service without a limiter, and with one in front. Switch on Simulate and raise the traffic to see what each version does when a script floods it.

    Before: Nothing in front

    After: Limiter at the gateway

    What changed

    • The abusive client is stopped at the gateway, not at the service
    • Counters sit in one shared store, so every server sees the same count
    • Blocked requests cost almost nothing to answer

    Algorithms

    AlgorithmIdeaGoodBad
    Token bucketA bucket refills at a steady rate; each request takes a tokenAllows bursts, tiny memoryTwo numbers to tune
    Leaky bucketRequests join a queue processed at a fixed rateSmooth output rateBursts fill the queue, old requests delayed
    Fixed window counterCount per minute, reset at the boundarySimplestBurst across a boundary doubles the limit
    Sliding window logKeep a timestamp per request, count those within the windowExactMemory per request
    Sliding window counterWeight the previous window's count by overlapCheap and close to exactApproximate

    Token bucket is a strong default: it is cheap, and bursts are usually fine for real clients. The sliding window counter is a good choice when you need smoother accuracy.

    Token bucket in a few lines

    For each key store (tokens, last_refill_time). On a request:

    1. Add elapsed x refill_rate tokens, up to the bucket size.
    2. If at least one token is available, take it and allow the request.
    3. Otherwise reject.

    The algorithms in pictures

    Token bucket. Tokens drip into a bucket of fixed size; every request must take one.

    Figure SDA-CSD-01-2 · Token bucket decision · © forcsguy.com

    A walk through time (bucket of 4, refilled to full each minute):

    Figure SDA-CSD-01-3 · Token bucket over a minute · © forcsguy.com

    Leaky bucket. Requests wait in a bounded queue and leave at a fixed rate.

    Figure SDA-CSD-01-4 · Leaky bucket · © forcsguy.com

    Fixed window counter and its boundary problem. One counter per clock window is simple, but two bursts on either side of the boundary can pass double the limit.

    Figure SDA-CSD-01-5 · Fixed window boundary burst · © forcsguy.com

    Sliding window log. Keep a timestamp for every accepted request and count those inside the last window.

    Figure SDA-CSD-01-6 · Sliding window log (2 per minute) · © forcsguy.com

    Sliding window counter. Blend the previous window's count with the current one, weighted by how much of the previous window still overlaps the last minute.

    Figure SDA-CSD-01-7 · Sliding window counter estimate · © forcsguy.com

    Making it work across servers

    Counters must be shared, otherwise each server enforces its own limit and a client gets N times the allowance. A fast in-memory store such as Redis works well.

    • Use an atomic operation (INCR with expiry, or a small Lua script) so the check and the update happen together. A separate read then write lets two servers both slip through.
    • Put the key in a predictable shape: rate:{user}:{rule}:{window}.
    • Partition keys across several Redis nodes for scale (consistent hashing, covered in lesson 2).
    • To save round trips, some systems keep local counters and sync periodically, accepting small overshoot.

    Why counters must be shared when there are several limiter servers:

    Figure SDA-CSD-01-8 · Why limiter servers need shared state · © forcsguy.com

    The system around the algorithm

    Figure SDA-CSD-01-9 · Detailed rate limiter design · © forcsguy.com

    The race condition when two servers read the same counter at once, and the fix:

    Figure SDA-CSD-01-10 · Read-modify-write race on a counter · © forcsguy.com

    Responses and visibility

    Return HTTP 429. Include headers so clients can behave: how many requests are allowed, how many remain, and when they reset, plus Retry-After. Log rejections and watch them, since a sudden rise can mean an attack, a bug in a client or a limit set too low.

    Going deeper

    Two races hide in "read, check, write". If two requests read the counter at 3 at the same moment, both write 4 and one request goes uncounted. A lock fixes it but slows every request; the usual answers are an atomic script that does the read, check and increment in one step inside Redis, or a sorted set that stores one timestamp per request so each request is a single atomic add.

    Many limiter servers need shared state. If each server counted only the traffic it sees, a client could send half its requests to each and double its quota. Sticky routing (always the same limiter for a client) helps but breaks when servers change and uneven load builds up. A central store such as Redis, or periodic sync with eventual consistency, is the common fix. Across regions, accept a little over-admission in exchange for not paying a cross-ocean round trip on every request.

    Where the rules live. Keep rules as data on disk or in config (for example "login: 5 per minute", "marketing messages: 5 per day"), have workers refresh them into a cache, and let the limiter read them from there, so tightening a rule never needs a deploy.

    Measure it. Watch two things: rules that are too strict (many valid users rejected) and an algorithm that cannot absorb a flash-sale burst. In the second case a token bucket, which allows short bursts, is the usual swap.

    Other layers and the client's side. The same idea works lower down, for example per IP address in the network layer rather than per user in HTTP. Well-behaved clients cache responses, respect the limit headers, handle the rejection gracefully, and back off before retrying.

    An approximate sliding-window counter blends the previous window's count (weighted by how much of it still overlaps) with the current one. It assumes traffic was even in the previous window; published tests by one large CDN found only a tiny fraction of requests were misjudged, so for most uses the saving in memory is worth it.

    Failure and edge cases

    • Limiter store down: usually fail open (let requests through, alert loudly) so you do not turn a limiter outage into an API outage. For security-sensitive endpoints (login attempts) you may prefer failing closed.
    • Clock differences between servers: base windows on the store's clock, not each server's.
    • Hard versus soft limits: some rules throttle (delay), others reject.
    • Many identities: also limit by IP for anonymous traffic, and watch for one client rotating keys.

    A worked example: setting the limits

    Say your public API has a free plan and a paid plan. You decide a free client may make 60 requests per minute with bursts up to 10, and a paid client 600 per minute.

    • Token bucket for the free plan: capacity 10, refill 1 token per second. A client idle for 10 seconds can fire 10 requests at once (the burst) and then settles to 1 per second. After a 429, it must wait about a second for the next token.
    • How much traffic is that? If 50,000 free clients all use their full allowance, that is 3,000,000 requests per minute, or 50,000 per second. You almost never see that, because most clients use a fraction. Sizing from the allowance gives the worst case; sizing from observed use gives the normal case. Plan the limiter and the servers behind it for the first, and alert on the second.
    • Counter memory: a token bucket needs two numbers per client (tokens, last refill time), about 16 bytes plus key overhead, say 100 bytes. For 10 million active clients that is about 1 GB, comfortably within one Redis node. A sliding window log would store a timestamp per request, up to 60 per client, which is 5 to 10 times more, one reason counters and buckets are the usual choice.

    Figure SDA-CSD-01-11 · Choosing limits by plan · © forcsguy.com

    Walking through a rejected request

    1. A client sends its 61st request in a minute.
    2. The edge gateway extracts the key (API key, falling back to IP address) and asks the limiter for that key.
    3. The limiter reads the bucket from the shared store, sees no tokens, and answers "no" without touching the application servers.
    4. The gateway returns HTTP 429 with a Retry-After header and, if you publish them, headers such as X-RateLimit-Limit and X-RateLimit-Remaining, so well-behaved clients can slow themselves down.
    5. The rejection is counted in metrics. A rapid rise from one key suggests abuse; a rise from many keys suggests your limit is too tight or a new client release is misbehaving.

    The cost of refusing is tiny compared with the cost of doing the work, which is the whole point: the limiter's decision must be much cheaper than the request it protects.

    When the limiter itself fails

    A limiter is in the path of every request, so decide in advance what happens when its shared store is slow or down:

    • Fail open (let requests through): users keep working, but you lose protection exactly when something odd is happening. Good for most public APIs, usually with a local fallback limit per server.
    • Fail closed (reject everything): safe for anything where overload is worse than refusal, such as an expensive or sensitive operation.
    • Keep a small local, in-memory limit on each server as a backstop, so even with the shared store down a single server cannot be flooded.

    Figure SDA-CSD-01-12 · Fail open with a local backstop · © forcsguy.com

    Mistakes people make

    • Limiting only by IP address. Many users share one address (offices, mobile carriers), and attackers rotate addresses. Prefer an API key or user id, with IP as a fallback.
    • Using the wrong clock. Limiter servers whose clocks drift apart count windows differently. Take time from the shared store, not each server.
    • Race conditions on counters. Reading a counter, adding one and writing it back lets two requests slip through together. Use an atomic increment or a small server-side script.
    • No visibility. Without rejection metrics you cannot tell abuse from a limit set too low.
    • Rejecting without guidance. Send Retry-After so clients can back off properly instead of retrying immediately and making things worse.

    Try it yourself

    Open the System Builder challenge A noisy client. One abusive client sends 97% of the traffic. Try to survive it by adding servers (you cannot, within 12), then switch on the rate limiter and watch the real users' errors disappear. Then build the sliding window rate limiter lab and see the boundary burst for yourself. You can also open the noisy-client design on the free canvas and place the rate limiter where you think it belongs.

    More on this site

    Open this lesson with its quiz and exercise

Go deeper on this

A path through videos, articles, other case studies and code on the same ideas as HTTP/3: the past, the present, and the future.

  1. Warm upGet the vocabulary first.

  2. WatchHow others solve the same problem, on video.

    Videos belong to their creators and play from YouTube. More on YouTube (opens in a new tab)

  3. ReadEngineers explain it in their own words.

  4. See it in another companyThe same ideas, a different system.

  5. Read the codeSee how it looks when it is real.

Keep learning

Loading community…