Beyond the Basics: Production Serverless Patterns for Extreme Scale • Janak Agarwal • GOTO 2025
This presentation by Janak Agarwal from AWS provides a deep dive into scaling serverless applications for mission-critical, high-traffic workloads. It explores AWS Lambda's rapid scaling capabilities for handling extreme traffic bursts and introduces advanced patterns like Provisioned Concurrency for cost optimization during steady-state operations.
Scaling applications to handle unpredictable, high-traffic events like concert ticket sales or viral content is a significant engineering challenge. A traditional approach often forces a difficult choice: under-provision and risk outages during traffic spikes, or over-provision and incur high costs from idle capacity. Serverless computing, specifically AWS Lambda, offers a solution that elegantly manages these “bursty” workloads.
The Serverless Scaling Advantage
Unlike traditional virtual machines or containers that require manual fine-tuning of auto-scaling policies, serverless platforms abstract this complexity away. The key benefits include:
- Automatic Management: AWS automatically handles all patching for the host, microVM, and language runtime, for both security and performance.
- Scale to Zero: You are not charged for idle capacity. If there are no requests, you pay nothing.
- Rapid Auto-Scaling: Serverless services are designed to scale up and down in response to incoming events faster than any other form of compute.
How AWS Lambda’s Concurrency Works
To understand Lambda’s scaling, it’s essential to grasp its concurrency model.
- Execution Environment: When an event triggers a function, Lambda creates a “sandbox execution environment” to process it. The initial creation of this environment is known as a cold start.
- Environment Reuse: After a request is processed, Lambda keeps the execution environment warm for a period. If another request arrives shortly after, it’s directed to this warm environment, eliminating cold start latency. You are not billed for this idle, warm time.
- Scaling Out: If a new request arrives while all existing execution environments are busy processing other requests, Lambda automatically creates a new environment to handle the new request. This process repeats as needed, allowing the application to scale concurrently.
This model ensures you only pay for the time your code is running, while the platform handles the creation and reuse of environments to optimize for performance.
Built for Extreme Scale
Lambda’s scaling mechanism is designed for massive, sudden traffic spikes. For each function in your account, you get:
- An initial burst of 1,000 concurrent execution environments immediately.
- An additional 1,000 environments every 10 seconds thereafter.
This scaling rate is per function, meaning different microservices within your application can scale independently of one another. In just over three minutes, a single function can scale to handle 16,000 to 18,000 concurrent requests, which can translate to tens of thousands of requests per second, depending on the function’s duration. For a developer handling a bursty workload, the required action is simply nothing—the platform scales automatically.
Cost Optimization for Quieter Periods with Provisioned Concurrency
While Lambda excels at handling peaks, most applications have quieter, steady-state periods. To optimize costs during these times, Lambda offers Provisioned Concurrency. This feature pre-initializes a specified number of execution environments, keeping them ready to respond instantly with zero cold starts.
The pricing model for Provisioned Concurrency includes three dimensions: requests, duration, and a nominal fee for the provisioned capacity itself. However, if you drive good utilization, you receive up to a 16% discount on the duration cost.
There are two ways to manage Provisioned Concurrency:
- Scheduled Auto-Scaling: Ideal for predictable workloads, like a cron job that runs at the top of the hour. You can schedule capacity to scale up just before the event and scale down immediately after.
- Target Tracking Auto-Scaling: A more dynamic approach where you set a target utilization metric (e.g., CPU utilization). The auto-scaler will then adjust the provisioned capacity up or down to maintain that target.
Handling the Unexpected
Even with Provisioned Concurrency configured for your baseline traffic, you remain prepared for unexpected spikes. If requests exceed the provisioned capacity, Lambda seamlessly spills over to the on-demand model, leveraging its rapid scaling capabilities (1,000 new environments every 10 seconds) to handle the excess load without any availability drop. Once again, the developer is required to do nothing.
Additional Best Practices
- Disable Provisioned Concurrency for Test Workloads: There is no need to test the scaling mechanism itself in non-production environments. Turn it off to save costs.
- Use Power Tuning: This open-source tool helps you find the optimal memory configuration for your function. Since CPU is allocated proportional to memory, this ensures you are not over-provisioning resources, balancing cost and performance.
- Adopt Graviton (ARM-based) Instances: Switching your functions to the ARM architecture provides a 20% price discount and up to a 34% better price-performance ratio.
- Leverage AWS Countdown: For large, planned events, coordinate with your AWS account team. They can engage the Countdown service to ensure all underlying AWS services are prepared for your specific workload, guaranteeing a seamless experience.