Compute at the edge
Run small handlers on Edge Functions next to the user and keep heavy work on the App Server, so cheap requests skip the trip to the origin.
Answer the cheap, common requests at the edge and send everything else to the origin.
Move up when#
Pages and reads from far Users are slow even with a regional copy.
The origin spends capacity on tiny requests such as redirects and header changes.
A cold start on a function hurts a user-facing request.
The Design#
Drag to pan. Hold Ctrl or Cmd and scroll to zoom.
| Where | Setting | Value | Why |
|---|---|---|---|
| Edge Function | Stack | node | The edge runs JavaScript or TypeScript, and Rust or Go built to WebAssembly. A PHP Stack is refused there. |
| App Server | Instance size | medium | Medium takes the kinds that are too heavy for the edge. |
| Database | Instance size | medium | Both tiers still call it, so the edge saves the user hop and not the query. |
| Link Load Balancer → Edge Function | Kinds carried | page,read | Pages and reads fit the edge CPU ceiling. Anything heavier is killed there. |
| Link Load Balancer → App Server | Kinds carried | write,login,search,upload,bot | Logins and uploads cost more CPU than an edge handler may spend, and writes belong beside the Database, so these go to the App Server. |
Research this Design needs: Load balancing, Edge compute, Node.js, Content delivery.
The Load Balancer sends pages and reads to the Edge Function and the heavier kinds to the App Server. Both call the Database. This picture runs in one region, so it shows the split of kinds and the CPU ceiling, not the saved distance.
Why it works#
An Edge Function starts in milliseconds with no cold start, and it bills per request. It runs your Service's Stack, so the Stack must be JavaScript or TypeScript, or Rust or Go built to WebAssembly. A PHP, Ruby or Python Stack is refused there.
A handler has a CPU ceiling instead of a box. A request that needs more is killed as a timeout, so a login's password hash or an upload does not fit.
What it costs#
An edge handler that calls the Database on every request still pays the trip, so it saves the user hop and not the query. One Edge Function serves only its own region, so copy it per region. It cannot hold a working set, since the memory is small. A Company on PHP must migrate its Stack first, which costs Dev Hours.
In Quorum#
Place an Edge Function and set a Stack that compiles for it. Research Edge compute, which needs Content delivery. A live Edge Function also holds the edge cache that a CDN answers reads from. The Certificate expired incident applies to it. The next rung, disaster recovery and a failover region, covers losing a whole region.