• Web Development
  • Cloud
  • Performance

Edge and Serverless Runtimes: Where Your Web App Should Run

Edge functions and serverless runtimes run code close to users with no servers to manage. When to use edge, serverless or a server for your web app.

1 min read
World map network representing edge and serverless runtimes

Modern web apps can run their server code in three places: on a traditional long-running server, in serverless functions that start on demand, or at "the edge", in lightweight runtimes distributed close to users around the world. Platforms like Vercel, Cloudflare Workers and Netlify make edge and serverless easy to adopt. The right choice depends on what each part of your app actually does.

The three options

Traditional server (Node.js on a VM or container)

  • Long-running, with full Node.js, persistent connections and background jobs.
  • Best for WebSockets, heavy processing, and anything needing steady state.

Serverless functions

  • Start per request and scale automatically, so you pay for usage.
  • Best for APIs, form handling, webhooks and most server-rendered pages.
  • Watch for cold starts and execution time limits.

Edge runtimes

  • Tiny, fast-starting runtimes in many locations worldwide.
  • Best for redirects, authentication checks, personalisation, A/B tests, and serving cached pages quickly.
  • Limited APIs: no full Node.js, and keep database round trips to a minimum.

A practical split for a typical site

  • Static and cached pages: served from a CDN.
  • Middleware (auth, redirects, geolocation): at the edge.
  • APIs and server-rendered pages: serverless, close to your database.
  • Real-time features and long jobs: a regular server or a queue worker.

A key rule: put compute near your data. An edge function in Mumbai calling a database in the US on every request is slower than a serverless function sitting next to the database.

A real lesson

Platform features can conflict with app code. On this site, a host-level redirect and an app-level redirect fought each other and caused an outage. Here's that write-up.

The right architecture for your app

At NextGen Fusion, our web development company in Lucknow, we deploy Next.js and Node.js apps on Vercel, AWS and other platforms, choosing edge, serverless or servers per feature.

Talk to me about your app's architecture.

Sources

  1. Vercel: Functions documentation
  2. Cloudflare Workers documentation
Ritesh Kumar Giri

Written by

Freelance full-stack and WordPress developer in Lucknow. I build WooCommerce and Shopify stores, and custom Next.js platforms, for businesses across India.