TalksAWS re:Invent 2025 - Best practices for serverless developers (CNS403)
AWS re:Invent 2025 - Best practices for serverless developers (CNS403)
Serverless Best Practices for Developers
Scaling Serverless Applications
Serverless is the default way to build cloud applications and enables rapid growth
Followed the journey of Emily, who started with a single Lambda function and scaled to 60 global locations processing 3.8 million orders per year
Key principles for scaling serverless applications:
Right-Sizing Functions: Each Lambda function should have a single clear responsibility, with the right amount of memory allocated for performance and cost optimization
Organizing Infrastructure: Use a pragmatic approach for repos, stacks, and services based on current needs, not future theoretical perfection
Enabling Team Autonomy: Allow teams to choose runtimes and tooling based on their expertise, aligned with domain-driven organization
Transitioning from Synchronous to Asynchronous
Synchronous architecture led to cascading failures and poor user experience during peak traffic
Moved to an event-driven, asynchronous design using services like Event Bridge, SQS, and AppSync
Provides immediate response to the client, with asynchronous processing in the background
Ensures failures in one system don't break others, and allows independent scaling of services
Leveraged Lambda's event source mapping for efficient asynchronous processing from various event sources
Detailed best practices for SQS configuration, including visibility timeout, retry policy, dead-letter queues, and flow control
Reducing Unnecessary Code
Avoided maintaining unnecessary Lambda functions by using direct service integrations and configuration-as-code
Used API Gateway to directly integrate with services like DynamoDB, SQS, and Step Functions
Leveraged Event Bridge's built-in transformation and filtering capabilities to replace simple data transformation Lambda functions
Utilized Step Functions' direct service integrations to remove many proxy Lambda functions
Optimizing Lambda Performance
Focused on memory optimization, cold start mitigation, and runtime upgrades to improve performance
Leveraged the relationship between memory, CPU, and cost to find the sweet spot for each function
Used tools like Lambda Power Tuning to automate the memory optimization process
Implemented techniques like lazy initialization, connection reuse, and native compilation to reduce cold starts
Upgraded runtimes to take advantage of performance improvements in newer versions
Building Resilient and Observable Systems
Implemented comprehensive error handling and retry mechanisms, including SQS dead-letter queues and Lambda on-failure destinations
Ensured idempotency for operations to handle retries, duplicates, and out-of-order processing
Utilized Step Functions' built-in retry and error handling capabilities
Improved observability by embedding business context in logs and metrics, leveraging tools like AWS CloudWatch and the Power Tools library
Enabled rapid troubleshooting and understanding of the business impact of technical issues
Cost Optimization
Understood the pricing models of serverless services like Lambda and Fargate to make cost-effective architectural decisions
Optimized logging costs by using structured logging, setting appropriate retention periods, and archiving to S3
Explored cost-saving strategies like Lambda Power Tuning, event filtering, and compute savings plans
Integrating AI Capabilities
Recognized that AI is just another workload that can be integrated into a serverless architecture
Used services like Bedrock Agent Core and MCP Gateway to build AI-powered features, such as a customer service chatbot and personalized recommendations
Leveraged the serverless principles of event-driven processing, automatic scaling, and pay-per-use pricing to efficiently incorporate AI capabilities
Key Takeaways
Serverless enables rapid growth and evolution of applications, but requires careful design and optimization
Asynchronous, event-driven architectures provide resilience, scalability, and better user experience
Reducing unnecessary code through direct service integrations and configuration-as-code can improve performance and reduce costs
Comprehensive error handling, observability, and cost optimization are crucial for building reliable and cost-effective serverless systems
Serverless principles can be applied to integrate AI capabilities, leveraging the benefits of scalability, flexibility, and cost-efficiency
Technical Details
Lambda function sizing and organization principles
Event-driven architecture using Event Bridge, SQS, and AppSync
Lambda's event source mapping for efficient asynchronous processing
Direct service integrations with API Gateway, Event Bridge, and Step Functions
Performance optimization techniques like memory optimization, cold start mitigation, and runtime upgrades
Observability tools like CloudWatch and Power Tools
Serverless pricing models for Lambda and Fargate
AI integration using Bedrock Agent Core and MCP Gateway
Business Impact
Enabled Emily's passion project to grow into a global success, processing 3.8 million orders per year with 35% cost reduction
Improved customer experience by providing immediate order confirmation and real-time progress updates
Increased revenue by implementing personalized recommendations and automating customer service
Reduced operational costs through right-sizing, event filtering, and observability-driven optimizations
Examples
Transformation from a single monolithic Lambda function to a well-organized, domain-driven serverless architecture
Migrating from synchronous to asynchronous processing to improve resilience and scalability during traffic spikes
Replacing numerous proxy Lambda functions with direct service integrations and configuration-as-code
Implementing comprehensive error handling and observability to enable rapid troubleshooting and understanding of business impact
Integrating AI-powered features like a customer service chatbot and personalized recommendations using serverless services
These cookies are used to collect information about how you interact with this website and allow us to remember you. We use this information to improve and customize your browsing experience, as well as for analytics.
If you decline, your information won’t be tracked when you visit this website. A single cookie will be used in your browser to remember your preference.