concept

Edge Function

Code executed at a CDN point of presence close to the user, in a constrained, fast-starting runtime, typically to modify or route a request before it reaches an origin.

edgelatencycdn

The value is removing a round trip to the origin for work that does not need origin state. At a hundred-millisecond origin distance, doing it at the edge is the difference between instant and noticeable.

What suits the edge: authentication and token validation, A/B test assignment, request routing and rewriting, header manipulation, geolocation-based personalisation, bot filtering, redirects, and generating a personalised shell around cached content.

The constraints are what shape the design. Runtimes are restricted — typically an isolate-based JavaScript or WebAssembly sandbox rather than a full container — with short CPU limits, small memory, and no persistent local state. Access to a database from the edge is usually a bad idea, because the edge is far from your data even though it is near the user, which converts a saved round trip into a longer one.

The architectural principle worth stating: the edge is for computation that needs the request but not your data. Once a function must read or write shared state, its latency is dominated by distance to that state, and the edge advantage disappears — which is why edge-adjacent key-value and replicated data services exist, and why they come with eventual-consistency semantics.