One Lambda Function OR Multiple Lambda Functions
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
Choosing between one large Lambda and multiple smaller Lambdas is an architecture decision about scaling, ownership, and operational risk. A single function can be simpler at the start, while multiple functions improve isolation and independent evolution. The right answer depends on workload shape and team structure, not on a fixed rule.
Single-Function Router Pattern
One Lambda can route requests by action or path.
This pattern is effective for early-stage services where operations share dependencies and release cadence.
Strengths and Limits of One Function
Strengths:
- lower infrastructure surface area
- one deployment unit
- fast bootstrap for small teams
Limits:
- broader IAM scope unless heavily segmented
- shared cold-start profile across unrelated operations
- harder incident isolation as routes grow
- one deployment can affect all capabilities
As complexity rises, this pattern can become an operational bottleneck.
Multiple-Function Pattern
Splitting functions by capability improves isolation.
Each function can scale, fail, and deploy independently.
Benefits of Multiple Functions
- least-privilege IAM per operation
- per-route memory and timeout tuning
- clearer ownership boundaries for teams
- targeted rollback and safer releases
Tradeoff is higher infrastructure management overhead, which can be controlled with templates and shared tooling.
Cost and Cold-Start Considerations
Many teams assume one function is always cheaper. In practice, cost depends on invocation profile, package size, and runtime tuning.
Important factors:
- package size and dependency bloat
- provisioned concurrency for critical paths
- memory settings per workload
- idle traffic distribution
A large monolithic function with heavy dependencies can increase cold-start latency for all routes, including simple operations.
Security and Compliance Angle
Security boundaries are often the deciding factor:
- if one operation requires elevated access, separate it
- if audit rules demand distinct logs and controls, separate functions
- if data domains differ by sensitivity, isolate aggressively
Security-driven decomposition is usually easier than retrofitting permissions later.
Hybrid Migration Strategy
A practical path:
- start with one function for MVP speed
- extract high-traffic route first
- extract high-risk security route second
- keep shared libraries versioned and minimal
This balances delivery speed with progressive hardening.
Observability Requirements
Regardless of architecture:
- include request correlation IDs
- emit structured logs with route or function labels
- track latency and error metrics per operation
- define retry and idempotency behavior clearly
Without observability discipline, both designs become difficult to operate.
Shared Code and Packaging Strategy
When using multiple functions, organize shared code in versioned libraries instead of copy-pasting utilities into each deployment package. This keeps bug fixes consistent and reduces review noise. At the same time, avoid pulling every shared dependency into every function, because oversized packages hurt cold-start behavior.
Deployment Pipeline Design
Independent functions are most valuable when pipelines support selective deploy and rollback. If your CI process always deploys every function together, you lose much of the isolation benefit. Invest early in per-function promotion controls and smoke tests so architecture and operations stay aligned.
Common Pitfalls
- Keeping one function after clear domain and security boundaries emerge.
- Splitting too early into many functions without shared deployment standards.
- Reusing overly broad IAM policies across supposedly isolated functions.
- Ignoring package size and dependency impact on cold starts.
- Migrating function boundaries without updating monitoring dashboards and alerts.
Summary
- One Lambda is simple and fast for early delivery.
- Multiple Lambdas offer stronger isolation, tuning, and ownership clarity.
- Choose based on scaling, security, and team boundaries.
- Use a staged hybrid migration as complexity grows.
- Maintain strong observability and deployment discipline in either model.

