Function-as-a-Service (FaaS) is one of the most hyped infrastructure patterns of the past decade. AWS Lambda, Cloudflare Workers, Google Cloud Functions, Azure Functions—these platforms promise to eliminate server management entirely.
But like any architectural decision, FaaS involves trade-offs. Let's break down what FaaS actually is, when it shines, and when it becomes more problem than solution.
What is Function-as-a-Service?
FaaS is a cloud computing model where you deploy individual functions rather than full applications. The cloud provider handles everything else: servers, scaling, load balancing, and infrastructure management.
Here's how it works:
- You write a function that handles a specific task
- You deploy it to a FaaS platform
- The platform runs your function in response to events (HTTP requests, database changes, scheduled triggers)
- You pay only for the compute time your function actually uses
A simple example:
// AWS Lambda function
export const handler = async (event: APIGatewayEvent) => {
const { userId } = JSON.parse(event.body);
const user = await database.getUser(userId);
return {
statusCode: 200,
body: JSON.stringify(user),
};
};// AWS Lambda function
export const handler = async (event: APIGatewayEvent) => {
const { userId } = JSON.parse(event.body);
const user = await database.getUser(userId);
return {
statusCode: 200,
body: JSON.stringify(user),
};
};No servers to provision. No capacity planning. The platform scales from zero to thousands of concurrent executions automatically.
Popular FaaS Platforms
AWS Lambda
The original and most mature FaaS platform. Deep integration with the AWS ecosystem—API Gateway, DynamoDB, S3, SQS, and dozens more services.
Strengths: Mature ecosystem, extensive triggers, strong enterprise adoption Limitations: Cold starts can hit several seconds, complex pricing model
Cloudflare Workers
Runs on Cloudflare's edge network, executing functions in data centers close to users. Built on V8 isolates rather than containers, resulting in much faster cold starts.
Strengths: Sub-millisecond cold starts, global edge deployment, simple pricing Limitations: Different runtime (not full Node.js), limited execution time
Google Cloud Functions / Azure Functions
Similar to Lambda with their respective cloud ecosystem integrations.
Quick Comparison
| Aspect | AWS Lambda | Cloudflare Workers | Google Cloud Functions |
|---|---|---|---|
| Cold Start | 100ms - 3s | < 5ms | 100ms - 2s |
| Max Duration | 15 minutes | 30 seconds (workers) | 9 minutes |
| Memory | Up to 10GB | 128MB | Up to 32GB |
| Pricing Model | Per request + duration | Per request | Per request + duration |
| Best For | Complex AWS integrations | Edge computing, APIs | GCP-native apps |
When FaaS Makes Sense
FaaS platforms excel in specific scenarios:
Event-driven workloads — Processing uploaded files, responding to database changes, handling webhooks. These sporadic, unpredictable workloads are exactly what FaaS was designed for.
APIs with variable traffic — An endpoint that handles 10 requests one hour and 10,000 the next. FaaS scales automatically without paying for idle capacity.
Scheduled tasks — Nightly reports, periodic cleanup jobs, scheduled notifications. No need to keep a server running 24/7 for tasks that run minutes per day.
Prototypes and MVPs — When you're validating an idea, FaaS lets you ship without infrastructure decisions. You can always migrate later if needed.
Microservices at the edge — Cloudflare Workers and similar edge platforms can run logic close to users, reducing latency for global applications.
Evaluating your architecture options? We help teams make informed infrastructure decisions—whether that's FaaS, containers, or a hybrid approach tailored to your specific needs.
The Hidden Costs of FaaS
Here's where the marketing stops and reality begins. FaaS has real limitations that can become serious problems at scale.
Cold Start Latency
When a function hasn't been invoked recently, the platform needs to initialize a new execution environment. This "cold start" can take anywhere from 50 milliseconds to several seconds, depending on:
- Runtime (Python/Node.js start faster than Java/C#)
- Package size (more dependencies = slower starts)
- VPC configuration (adds significant latency on AWS)
- Platform (Cloudflare Workers are much faster than Lambda)
For user-facing APIs where latency matters, cold starts can tank your user experience. Workarounds exist (provisioned concurrency, keeping functions warm), but they add cost and complexity.
Cost Unpredictability
The promise: "Pay only for what you use." The reality: "Surprise bills when traffic spikes."
FaaS pricing is based on:
- Number of invocations
- Execution duration
- Memory allocated
At low traffic, this is genuinely cheaper than running servers. But the math changes as you scale:
- A function running 1 million times per month at 200ms average duration can cost more than a dedicated server running 24/7
- Memory-intensive workloads pay a premium since CPU scales with memory allocation
- High-frequency, short-duration calls (like edge middleware) can generate surprising bills
One common pattern: teams start on FaaS for simplicity, then migrate to containers when they realize they're paying 3-5x what dedicated compute would cost.
Vendor Lock-in
Each FaaS platform has its own:
- Event format and handler signature
- Deployment configuration
- Available triggers and integrations
- Runtime limitations
Migrating from AWS Lambda to Cloudflare Workers isn't just changing a deployment target—it's rewriting code, rethinking architecture, and retesting everything.
This lock-in compounds over time. The more you integrate with platform-specific services (Step Functions, DynamoDB Streams, Workers KV), the harder migration becomes.
Resource Constraints
FaaS functions have hard limits:
- Execution time — Lambda caps at 15 minutes, Workers at 30 seconds
- Memory — Typically 128MB to 10GB, with CPU scaling proportionally
- Payload size — Request/response bodies are limited (6MB on Lambda)
- Concurrent executions — Account-level limits can throttle traffic spikes
Long-running processes, large file processing, or compute-intensive workloads simply don't fit the FaaS model.
Debugging and Observability Challenges
Traditional debugging doesn't work with distributed, ephemeral functions:
- No attaching debuggers to production
- Stack traces span multiple services
- Logs are scattered across invocations
- Reproducing issues locally is difficult
You're dependent on the platform's monitoring tools, which vary in capability. Building proper observability requires additional services (X-Ray, custom tracing), adding cost and complexity.
Testing Complexity
Unit testing function logic is straightforward. Integration testing the full system—with all its event triggers, permissions, and platform services—is not.
Local development environments like SAM Local or Miniflare help, but they don't perfectly replicate production behavior. "Works locally, fails in Lambda" is a common frustration.
The Architecture Question
The real question isn't "Should we use FaaS?" It's: what does our system need to do, and what constraints can we accept?
FaaS works well when:
- Workloads are event-driven and sporadic
- Traffic is unpredictable
- Functions are stateless and short-lived
- You're building on AWS/GCP and want deep integration
FaaS becomes problematic when:
- Latency requirements are strict (cold starts hurt)
- Traffic is consistent and high-volume (containers are cheaper)
- Workloads need more than 15 minutes execution time
- You need portability across cloud providers
- Debugging and observability are critical
Many successful architectures use FaaS selectively—for webhook handlers, scheduled jobs, and event processing—while running core APIs on containers or traditional servers.
Making the Decision
Choose FaaS when:
- You're processing events (file uploads, queue messages, webhooks)
- Traffic is spiky and unpredictable
- You want zero infrastructure management
- Your functions are stateless and complete quickly
Consider alternatives when:
- You have consistent, high-volume traffic
- Latency requirements are strict
- You need long-running processes
- Cost predictability is important
- You want to avoid vendor lock-in
There's no universal right answer. The best architecture depends on your specific requirements, traffic patterns, team expertise, and business constraints.
The mistake is choosing FaaS because it's trendy, or avoiding it because it's "not real infrastructure." Make the decision based on trade-offs you actually understand.
Not sure which architecture fits your needs? We help teams evaluate their options and design infrastructure that scales—whether that's FaaS, containers, or a hybrid approach. Get clarity before you commit.
