Introduction
The terms serverless and traditional describe two models for running applications. In the serverless model, the servers are provisioned and managed by the cloud provider, and charges apply only for the compute that is consumed. In the traditional model, servers or containers are run continuously and are managed by the developer or the operations team. A container is a packaged unit that holds an application together with everything it needs to run. This guide compares the two models and explains when each should be chosen.
What is being compared?
In the serverless model on AWS, application logic is placed in functions that are run by AWS Lambda in response to events, and no server is managed by the developer. In the traditional model, the application runs as a continuously operating process on virtual servers, such as Amazon Elastic Compute Cloud instances, known as Amazon EC2, or on containers managed by a service such as Amazon Elastic Container Service, known as Amazon ECS. The essential difference is who manages the servers and how billing is calculated.
Why the choice matters
The model that is chosen affects cost, the way the application scales, the amount of operational work required, and the degree of control over the runtime. A runtime is the environment in which the application executes. A workload that is intermittent may be inexpensive under one model and wasteful under the other, and a workload that runs continuously may show the opposite result. Selecting the appropriate model is therefore an important early decision.
How each model works
In the serverless model, a function remains idle until an event triggers it. When traffic increases, additional copies of the function are run in parallel, and when traffic falls, capacity is released. No charge is incurred while no code is running. A delay known as a cold start may occur when a new environment must be initialized for the first request.
In the traditional model, one or more servers are kept running so that the application is always ready to respond. Scaling is achieved by adding or removing servers, either manually or through automatic scaling rules that the team configures. Because the servers run continuously, they are paid for whether or not they are handling requests, but no cold start occurs, and full control of the operating system and runtime is retained.
Architecture diagram
Advantages of serverless
- No server management. Provisioning, patching, and scaling are handled by AWS.
- Automatic scaling. Capacity is matched to demand without manual configuration.
- Pay for use. Idle capacity is not paid for.
- Faster start for small teams. Less infrastructure work is required to reach production.
Where traditional is stronger
- Long-running work. Processes that run continuously or exceed the serverless execution limit are better suited to servers or containers.
- Predictable low latency. An always-on process avoids the cold start that a serverless function may incur.
- Full control. The operating system, runtime, and specialized hardware can be controlled directly.
- Steady high volume. At constant high load, a reserved server can be less expensive than per-request charges.
When to choose each
- Serverless suits event-driven work, variable or unpredictable traffic, and small teams that wish to avoid infrastructure management.
- Traditional suits long-running processes, workloads that require full control of the runtime, and steady high-volume traffic.
- Many systems combine both, using serverless functions for bursty work and containers for steady components.
Best practices
- The traffic pattern and the runtime requirements should be assessed before a model is chosen.
- The two models should be combined where each is best suited, rather than one being forced onto every component.
- Cost should be estimated for the expected traffic under both models, because the cheaper option depends on the workload.
- Latency requirements should be considered, because cold starts affect serverless functions on infrequently used paths.
Common mistakes
- Serverless is chosen for a continuously busy workload, where a container would be simpler and cheaper.
- A traditional server is chosen for rarely used work that would cost very little under serverless.
- Cold start latency is overlooked on paths that require a fast and predictable response.
- Serverless is assumed to remove all operational work, when monitoring, security, and cost control remain necessary.
Related AWS services
- AWS Lambda runs the functions that make up a serverless application.
- Amazon EC2 provides virtual servers for the traditional model.
- Amazon ECS runs and manages containers for the traditional model.
- Amazon API Gateway can place an API in front of either model.
Frequently Asked Questions
- Is serverless cheaper than traditional hosting?
- It depends on the workload. For intermittent or unpredictable traffic, serverless is often cheaper, because charges apply only while code is running. For high, steady traffic, a traditional server or container can be cheaper.
- Can serverless and traditional models be combined?
- Yes. Many systems use both. Serverless functions may be used for event-driven or bursty work, while long-running components run on containers or servers.
- Is serverless always the better choice?
- No. Serverless reduces operational effort and scales automatically, but it imposes limits such as the maximum execution time and cold starts. Continuous workloads that require full control may be better served by a traditional model.
- What is a cold start, and does it affect traditional applications?
- A cold start is the delay that occurs when a serverless environment must be initialized before the first request is served. Traditional applications that keep servers running do not experience cold starts in the same way.
- Does serverless remove all operational work?
- No. Servers no longer need to be managed, but monitoring, security, cost control, and application design remain the responsibility of the developer.
This article is the summary. The book is the full, continuously updated reference: choosing between models, cost control, scaling, and complete serverless architectures.
View the book