# 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



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](https://wiki.playquorum.dev/components/edge.md) and set a Stack that compiles for it. Research [Edge compute](https://wiki.playquorum.dev/research/edge-compute.md), which needs Content delivery. A live Edge Function also holds the edge cache that a CDN answers reads from. The [Certificate expired](https://wiki.playquorum.dev/incidents/certificate.md) incident applies to it. The next rung, [disaster recovery and a failover region](https://wiki.playquorum.dev/patterns/disaster-recovery-and-failover-region.md), covers losing a whole region.

Source: https://wiki.playquorum.dev/patterns/compute-at-the-edge
