Compute
Serverless Function
A single piece of code that runs on demand in response to an event, billed only for its execution time.
A serverless function is a small unit of code that runs when something triggers it, an HTTP request, a file upload, a scheduled timer, then shuts down. You're billed for the milliseconds it runs and nothing while it sits idle. AWS Lambda popularized the model, and Cloudflare Workers, Vercel, and Netlify all offer their own take.
The fit is excellent for event-driven and bursty work: image resizing, webhook handlers, API endpoints with uneven traffic. A function called a thousand times a day costs pennies, and one called a million times scales without you touching anything. No servers to size, patch, or keep warm.
The limits are the flip side. Functions have execution time caps, cold-start latency on the first call, and pricing that gets hard to predict at high volume. Long-running jobs and stateful workloads fit poorly. Use them for the spiky edges of an app, not its steady core.
Go deeper
- Where to Host a Node.js API in 2026PaaS, VPS, or serverless for an Express/NestJS/Fastify backend: what each actually costs, where each breaks, and the memory ceiling nobody warns you about.