Infrastructure: edge computing
Edge computing runs a small function near the user on every request, before or after the cache answers. The course covers what that function can read and change, and the limits of edge runtimes: JavaScript or WebAssembly, milliseconds of CPU, no database and eventually consistent key-value storage. It uses locale selection, read from the Accept-Language header, as a worked case. It weighs the cost of keeping logic in two places, compares an edge fix with a fix in Ruby, and ends with a locale negotiation exercise.
What you'll learn
- ✓What an edge function can read, rewrite, redirect or answer
- ✓The limits of edge runtimes: language, CPU time, state and cold starts
- ✓Why one URL with two correct locale responses complicates edge caching
- ✓The cost of a rule implemented at both the edge and the origin
- ✓Which state is safe to keep at the edge and which belongs at the origin
- ✓How to separate a product defect from a latency optimization before choosing a fix
Moving the decision, not the bytes
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.
Read the full lesson free →Curriculum
7 lessonsMoving the decision, not the bytes
Edge computing lets you write the small decision a CDN already makes near users, saving a distant round trip.
What actually runs at an edge
Edge runtimes offer JavaScript or WebAssembly, milliseconds of CPU, no database and only eventually consistent key-value storage.
The locale decision this app makes
This application ignored Accept-Language, and its cookie-based locale gives one URL two correct responses for an edge cache.
The cost of logic in two places
Duplicating a rule at the edge adds a second language, deploy pipeline, log destination and test suite.
State at the edge
Edge storage suits rare operator writes like flags, while user preferences fail read-your-own-writes and stay at the origin.
The cheaper fix first
Adding Accept-Language to set_locale in Ruby fixes the defect, leaving the latency question for later measurement.
Putting it together
A recap of the course and a challenge to implement negotiate_locale with parameter, session, weighted Accept-Language and default.