Moving the decision, not the bytes

Free preview 3 min to read

The senior course "Infrastructure: global CDN" drew a line: a content delivery network moves bytes, not computation. Edge computing is the attempt to move a little computation across that line, and the interesting question is how little you can move and still get the benefit.

What sits at an edge already

A content delivery network has machines near your users, running software that decides whether a cached copy may be served. That decision is already computation at the edge.

Edge computing lets you write that decision, and it's nothing more exotic than that.

The shape of the thing

A small function runs at the edge on every request, before the cache is consulted or after it answers.

It can read the request, including headers, cookies, path and the visitor's approximate location, and change what happens next. It can rewrite the path, choose a cache key, redirect, or return a response outright.

flowchart TB
  U["request arrives at the nearest edge"] --> F["edge function reads headers and cookies"]
  F --> D{"can this be answered here?"}
  D -->|yes| C["serve from the edge cache"]
  D -->|no| O["forward to the origin, far away"]
  F --> R["or redirect, or rewrite, without touching the origin"]

Why it exists

It exists because the useful decision is often tiny, and the round trip to make it isn't.

Deciding which of two cached variants a visitor should get takes microseconds. Asking an origin 200 milliseconds away to make that decision costs 200 milliseconds.

When the decision is small and the distance is large, moving the decision is the whole win. That ratio, more than any feature list, tells you whether edge computing applies to a given problem.

What it isn't

It isn't running your application at the edge; lesson 2 covers why that isn't on offer.

It isn't a replacement for the origin. Anything that needs your database, your session store or your full application code still goes home.

The useful mental model is a programmable front door: it can read who's knocking and decide which room to send them to, but the rooms are still where they were.

Key takeaways

  • A CDN already makes one decision at the edge: whether a cached copy may be served.
  • Edge computing lets you write that decision, where before you could only configure it.
  • The function reads headers, cookies, path and location, and it can rewrite, redirect or answer.
  • It pays when the decision is small and the distance to the origin is large.
  • It's a programmable front door, not a place to run your application.
Lesson 1 of 7 · free

Keep going with lesson 2

What actually runs at an edge

Edge runtimes offer JavaScript or WebAssembly, milliseconds of CPU, no database and only eventually consistent key-value storage.

A free account also gives you the quizzes, your progress and notes, and the discussion.

Type to start searching...