When to Use? #
Serverless isn’t just a tech trend or a cool marketing buzzword. It represents a paradigm shift in how we build, run, and scale software. But like all architectural technologies, serverless isn’t a universal solution to every problem. Many serverless adoption failures happen not because the technology is bad, but because it was applied in the wrong context or situation.
Adopting serverless requires an objective evaluation of application needs, traffic patterns, team capabilities, and financial aspects. We shouldn’t choose serverless just to look modern. We should choose it because our application’s workload characteristics genuinely need the advantages serverless offers. This article will pragmatically break down when we should use serverless and when we should avoid it.
Workload Characteristics That Fit Perfectly #
The key to successful serverless adoption lies in mapping our application’s workload patterns. There are several workload patterns that naturally fit the on-demand, event-driven execution model typical of serverless.
1. Unstable Traffic Patterns (Sporadic & Burst Traffic) #
If our application has highly fluctuating traffic — busy at certain hours and completely silent at others — serverless is the best choice.
flowchart TD
A["Incoming Traffic"] --> B{"Traffic Type?"}
B -->|"Stable / Constant"| C["Traditional Server / VM<br/>(resources optimally used)"]
B -->|"Spiky / Fluctuating"| D["Serverless<br/>(scale-to-zero when quiet,<br/>instant scaling when busy)"]Real-world examples of this scenario include:
- Payment Webhook Systems: Webhooks from payment gateways only arrive when a transaction succeeds. Transactions can be very busy during the day and almost zero at 2 AM.
- Marketing Campaign Applications: Micro-sites created specifically for seasonal promotions (like flash sales) that get flooded by thousands of users within 10 minutes, then go quiet for months.
- Notification Endpoints: Sending mass emails or push messages at specific times.
2. Event-Driven Data Processing Pipelines #
In event-driven architecture, serverless acts as a highly efficient async task executor. When an event occurs in the system, the cloud platform triggers a serverless function to process it.
flowchart LR
Upload["User uploads file to Storage"] -->|Event: ObjectCreated| Trigger["Cloud Platform triggers Function"]
Trigger -->|Process| Action1["Resize Image"]
Trigger -->|Process| Action2["Extract Metadata"]
Trigger -->|Process| Action3["Save Log to DB"]This pattern is very efficient because we don’t need to run a virtual server 24/7 just to wait for users to upload files. The function only spins up, processes the file for a few seconds, then shuts back down.
3. Scheduled Background Jobs / Cron #
Many applications have periodic tasks like generating daily reports at midnight, syncing databases every hour, or running weekly garbage collection.
Renting a dedicated VM for these scheduled tasks is a huge waste because the server will be idle over 95% of the time. With serverless, we can configure a time trigger (Cron schedule) to run the function at designated times and only pay for the short duration when the report is actually generated.
Financial Evaluation and TCO (Total Cost of Ownership) #
When comparing serverless costs with traditional servers (IaaS/VM), we often get trapped in comparing only the nominal raw compute bills. This is a big mistake. We need to calculate the Total Cost of Ownership (TCO), which includes operational costs, team work time, and resource efficiency.
Cost Scenario Comparison: VM vs. Serverless #
Let’s run a cost comparison simulation between renting a medium-spec Virtual Private Server (VPS) for $40/month and using serverless compute (like AWS Lambda or Google Cloud Run) for different traffic scenarios.
| Workload Scenario | Requests per Month | Avg Duration per Request | Traditional VM Cost (24/7 Uptime) | Estimated Serverless Cost (Only When Active) | Financial Winner |
|---|---|---|---|---|---|
| Experiment / Staging | 10,000 | 500 ms | $40.00 | $0.00 (Within Free Tier) | Serverless (Save 100%) |
| Internal Office App | 100,000 | 300 ms | $40.00 | ~$0.50 | Serverless (Save 98%) |
| Spiky Webhook API | 1,000,000 | 200 ms | $40.00 | ~$3.00 | Serverless (Save 92%) |
| Medium REST API | 10,000,000 | 150 ms | $40.00 | ~$22.00 | Serverless (Save 45%) |
| Constant High-Traffic API | 100,000,000 | 200 ms | $40.00 (may need $120 cluster) | ~$240.00 | Traditional VM (Cheaper) |
Why Serverless Can Be Cheaper? #
- Eliminates Idle Costs: We never pay for idle CPU and RAM.
- Reduces Management Costs (Ops Cost): We don’t need to hire dedicated DevOps engineers to monitor OS, configure security patching, or manage Kubernetes clusters. The time saved by the engineering team on infrastructure work is worth thousands of dollars.
Organizational Aspects and Team Velocity #
Technology choices don’t only affect application performance, but also the productivity and structure of our development team.
1. Advantages for Small Teams and Startups #
For startups or small teams with limited engineers, the burden of managing servers can be crippling cognitive load. Teams must split focus between writing product features and securing servers.
Team Focus Without Serverless:
[Writing Business Features: 50%] + [Managing Servers, Patching, Monitoring, OS: 50%]
Team Focus With Serverless:
[Writing Business Features: 90%] + [Configuring Serverless IaC: 10%]
With serverless, the entire low-level operational burden is shifted to the cloud provider. A small team of 2-3 developers can launch a globally scaled product and handle thousands of users without needing to hire a dedicated DevOps engineer from day one.
2. Accelerated Time-to-Market (TTM) #
Serverless cuts the operational bureaucracy of infrastructure provisioning. In the traditional era, creating one new microservice required coordinating with the infrastructure team to set up a VM, configure an IP, create a load balancer, and register DNS. This process could take days.
In the serverless ecosystem, developers can define infrastructure inside code configuration files (Infrastructure as Code) and deploy new functions within minutes. This makes the cycle of experimentation, user feedback, and new feature launches run much faster.
Decision Guide: Decision Tree #
To make the architectural decision process easier, we can use the following decision tree before determining whether a service is worth building on serverless.
flowchart TD
Start["Start Architecture Evaluation"] --> Q1{"Does the process run<br/>for more than 15 minutes?"}
Q1 -- "Yes" --> VM["Use Long-running VM / Container<br/>(e.g., AWS EC2, ECS, GCP GCE)"]
Q1 -- "No" --> Q2{"Does the app need<br/>consistent ultra-low latency<br/>(sub-10ms, no cold start)?"}
Q2 -- "Yes" --> VM
Q2 -- "No" --> Q3{"Is traffic stable<br/>and very high 24/7?"}
Q3 -- "Yes" --> VM
Q3 -- "No" --> Q4{"Does the team have<br/>dedicated resources for<br/>OS & network management?"}
Q4 -- "No" --> SL["Highly Recommended:<br/>Serverless Architecture"]
Q4 -- "Yes" --> Q5{"Want to optimize<br/>idle costs and speed up<br/>time-to-market?"}
Q5 -- "Yes" --> SL
Q5 -- "No" --> VMWhen Should Serverless Be Avoided? #
A good software engineer must be honest about the weaknesses and limitations of the technology they use. There are several critical scenarios where serverless would actually backfire, increasing operational costs and worsening system performance.
1. Long-Running Processes #
FaaS has strict execution time limits (timeout). For example, AWS Lambda limits maximum execution time to 15 minutes per invocation. If we have applications doing heavy compute like 3D video rendering, AI model training (ML training), large-scale big data processing, or WebSocket web servers requiring persistent connections for hours, serverless FaaS is a poor choice. We’ll frequently hit timeouts and the cumulative millisecond execution costs will skyrocket past standard VM rental costs.
2. Ultra-Low Latency Applications #
The cold start problem is an inherent characteristic of serverless. When a function hasn’t been called for a while, the cloud provider destroys its container to save resources. When a new request arrives, the cloud provider must prepare a new container, download the code, and initialize the runtime. This initialization process can take anywhere from 200 milliseconds to several seconds.
If our application is a real-time stock trading system, an online multiplayer game, or a core banking API that needs consistent responses under 20 milliseconds, serverless cold start will ruin our user experience.
3. Stable, Very High-Traffic Workloads #
When our application traffic is already huge, stable, and consistently predictable 24 hours a day, serverless efficiency disappears. The financial advantage of serverless comes from eliminating idle costs. But if our server CPU is working at 90% all the time with no idle, renting a VM at a flat monthly price (or even dedicating physical hardware) will be mathematically much cheaper than paying retail for billions of serverless function invocations.
Summary #
← Previous: Why Serverless? Next: Whisperings →
- Serverless is the best choice for unstable (spiky) traffic patterns, event-driven applications, scheduled tasks (cron), and testing/staging environments.
- Serverless TCO (Total Cost of Ownership) is highly efficient for small teams and startups because it eliminates infrastructure maintenance costs and idle resource payments.
- Serverless accelerates Time-to-Market by letting developers focus on writing code and automating infrastructure through code declarations (IaC).
- Avoid serverless if our application runs long compute processes (> 15 minutes), needs consistently ultra-low latency without cold start, or serves massive stable traffic 24/7.
- Use the decision tree diagram to rationally evaluate architectural feasibility before migrating infrastructure.