Edge functions are small pieces of an app's code that run on a content delivery network's servers, in cities near the users. So some requests are answered close by, and never travel to the app's main server far away. They are also called edge workers.
A content delivery network (CDN) first kept only copies of files, such as images. A copy is the same for every visitor. But many answers depend on who is asking: the visitor's language, the visitor's city, or whether the visitor is logged in. Before edge functions, every such request had to go to the app's own server. An edge function lets the developer write a few lines of code that work out the answer at the nearby server.
Here is a typical case. A language-learning app from Bengaluru teaches English to speakers of nine Indian languages. Its main server, called the origin, is in Mumbai. A learner in Chennai opens the app. Her request reaches the CDN's server in Chennai in about 8 milliseconds. There, an edge function runs. It reads the location that the CDN attaches to each request, which says Tamil Nadu. It also reads her login token, a signed piece of text that proves who she is, and checks the signature. This check takes about 2 milliseconds. The function then picks the Tamil version of today's lesson list from the CDN's stored copies, and sends it back. The Mumbai server is never asked.
Some requests must still go to Mumbai. For example, when she finishes a lesson, her score must be saved in the app's main database. So the edge function passes that request on to the origin. Out of every ten requests, perhaps one goes all the way back.
Why does this matter? A round trip from Chennai to Mumbai takes about 30 milliseconds, as the page on bandwidth and latency explains. Saving that time on every screen makes the app feel faster. It also means the main server handles far fewer requests. So the team can rent a smaller server from its developer cloud.
Edge functions have limits. Each one may use only a few milliseconds of computing and a small amount of memory for each request. They cannot run long jobs. They keep no data of their own from one request to the next, unless they use the CDN's storage. So the heavy part of the backend, such as the main database, stays on the main server.
How are edge functions different from a virtual private server? A virtual server runs all the time, in one place, and the team pays for every hour. An edge function runs only when a request arrives, in hundreds of cities at once, and the team pays for each request. Edge functions are one form of edge computing.