By Allan Adan · April 6, 2026 · 3 min read

An Introduction to Serverless Functions

#web development#engineering

Serverless functions have become a default way to run backend logic for web applications, yet the name is a source of confusion. Servers are very much involved; what changes is who manages them. A serverless function is a unit of code that a platform runs on demand, provisioning and scaling the underlying infrastructure automatically and billing only for execution. This article explains the model, how invocation and cold starts behave, where the approach fits, and the constraints that must inform any design built on it.

What “Serverless” Actually Means

In a traditional deployment, a developer provisions a server, keeps a process running continuously, and is responsible for scaling it under load. The process waits idle between requests, and that idle capacity is paid for regardless of use.

A serverless function inverts this. The developer writes a single handler, a function that receives a request and returns a response, and uploads it to a platform such as Vercel. The platform stores the code and runs it only when an event arrives, typically an incoming HTTP request. When traffic increases, the platform runs more concurrent copies; when traffic falls to zero, nothing runs and nothing is billed. The server has not disappeared, but its provisioning, scaling, and idle management have been delegated entirely to the platform.

Invocation and Cold Starts

Understanding the lifecycle of an invocation is essential to using functions well.

When a request arrives and no instance of the function is ready, the platform must create one: it allocates a runtime, loads the code, and initialises it before the handler executes. This initialisation is known as a cold start, and it adds latency to that first request. Once an instance exists, the platform keeps it available for a period, so subsequent requests reuse it and execute without the startup penalty. These are warm invocations.

Cold-start cost depends on the runtime and the amount of initialisation code, including the size of dependencies loaded at startup. For latency-sensitive paths, this matters. Lightweight runtimes that run at edge locations reduce cold-start time considerably and place execution physically closer to the user, at the cost of a more constrained execution environment. The practical guidance is to keep the initialisation path lean, importing only what a function needs and deferring heavy work until it is actually required.

Constraints to Design Around

The serverless model imposes characteristics that must shape the code written for it.

The most important is statelessness. Because instances are created and destroyed by the platform, a function cannot reliably retain data in memory between requests. Anything that must persist, a session, a counter, an uploaded file, belongs in an external store such as a database, a cache, or object storage. Code that assumes a long-lived process holding state in variables will behave unpredictably.

Functions also run under a maximum execution duration. Work that exceeds the limit is terminated, so long-running tasks such as large batch jobs or video processing are poor fits for a single invocation and are better handled by a queue with many short executions or by a dedicated long-running service.

A further consideration is connection management. Many concurrent function instances each opening a database connection can exhaust a database’s connection limit. Connection pooling intended for serverless environments, or a data layer designed for many short-lived clients, addresses this.

Finally, observability differs. Without a persistent process to attach to, debugging relies on structured logging and the platform’s tracing tools. Designing functions to emit clear, contextual logs from the outset pays dividends when diagnosing production behaviour.

Conclusion

Serverless functions trade the control and continuity of a managed server for automatic scaling, pay-per-use economics, and operational simplicity. They excel at event-driven, bursty, and independently scalable workloads such as API endpoints and webhooks. To use them well, a developer must respect their nature: keep initialisation light to limit cold starts, treat every invocation as stateless and externalise persistence, stay within execution limits, and design for many short-lived instances. Understood on these terms, serverless functions are a precise and powerful tool rather than a mysterious one.

Working on something like this? Let's talk →

Sources & references (2)