I cut Lambda costs by 98%. Here's how.


AWS FOR THE REAL WORLD
⏱️
Reading time: 8 minutes
🎯
Main Learning: 5 practical techniques to cut Lambda costs (memory, timeouts, ARM, batching, caching)
πŸ“
🎬

Hey Reader πŸ‘‹πŸ½

Lambda bills can sneak up on you. One function is often not expensive. But then you scale it up and πŸ’₯ it costs you $5,000.

Sounds familiar?

We had this exact problem with our Shopify fraud detection app. Orders coming in via EventBridge, each triggering its own Lambda.And the bill was $150/month for just one small function. After some changes, we got it down to $3.

Sponsored

Honeycomb - The End of Observability as We Know It

AI is transforming how we debug production issues. Instead of manually digging through logs and dashboards across multiple AWS accounts, AI can help you find root causes faster. Honeycomb's new blog post explores how speed matters in observabilityβ€”and how AI-powered tools are changing the game. Whether you're dealing with slow checkouts, cross-account debugging, or complex service interactions, understanding this shift is crucial for modern cloud applications.

Thank you to Honeycomb for sponsoring this content.

In this issue, I'll walk you through 5 tips that actually work. No generic "turn off unused Lambdas" advice.

Real patterns from real projects.

Rather watch a video? I've recorded one for you! 🎬

video preview​

Rather read? Here the post ✏️

5 Tips to Save Lambda Costs

πŸ“š This Week's Deep Dive

Lambda costs are based on GB per millisecond. Two dimensions: memory and time. Most optimization advice focuses on memory. But the real wins? Batching and architecture changes.

1. Understand Your Costs First

Set up cost allocation tags. Use Cost Explorer. Drill down by stack and function name. Without visibility, you're optimizing blind.

In SST, you can tag all functions with one transform:

$transform(sst.aws.Function, (args, _opts, name) => {
    args.tags ??= { 'function:name': `${$app.name}-${$app.stage}-${name}` };
  });

2. Right-Size Memory

Every Lambda logs a REPORT with max memory used vs allocated. Query it with CloudWatch Logs Insights. If max memory is way below allocated? You're overpaying.

Important: Memory also determines CPU. Cut memory too much and your function runs slower. Use Lambda Power Tuning to find the sweet spot.

3. Reduce Timeouts

Default timeout of 15 minutes? That's a cost time bomb. Query actual durations with Logs Insights. Set timeouts based on real p99 values, not worst-case fears.

4. Switch to ARM

ARM (Graviton2) is ~20% cheaper than x86. For new projects, ARM should be your default. Watch out for dependencies that don't support ARM, and bundling issues if your CI/CD runs on x86.

5. Use Your Lambda Less (The Big Win)

This is where the 98% savings came from.

Before: EventBridge β†’ Lambda (one per event). 700 concurrent Lambdas. Downstream system crashing. $280/month.

After: EventBridge β†’ SQS β†’ Lambda with batch size 40 + concurrency limit. $3/month.

Same for caching: store rules in the execution environment, use CloudFront for edge caching, cache at the database layer. Fewer invocations = lower costs.

That’s it for this week!

Quick recap:

  1. Tag your functions. Know what costs what.
  2. Right-size memory (but don’t kill your CPU).
  3. Set realistic timeouts.
  4. Use ARM for new projects.
  5. Batch everything. Seriously, batching is the cheat code.

Got Lambda cost wins of your own? Reply and tell us - we’d love to feature them.

See you soon! Sandro & Tobi

AWS for the Real World

We teach AWS for the real world - not for certifications. Join more than 10,500 developers learning how to build real-world applications on AWS.

Read more from AWS for the Real World

AWS FOR THE REAL WORLD ⏱️ Reading time: 8 minutes 🎯 Main Learning: How to pause Step Function workflows for human approval using the callback pattern πŸ“ Blog Post πŸ’» GitHub Repository 🎬 Watch on YouTube Hey Reader πŸ‘‹πŸ½ I've used this pattern in almost every project I've built. Whenever you need a human in the loop - approvals, reviews, manual checks - and you still want to see what's happening, Step Functions are perfect. Lambda is my go-to for almost everything. APIs S3 triggers event consumers...

AWS FOR THE REAL WORLD ⏱️ Reading time: 5 minutes 🎯 Main Learning: How to make Claude write production-ready Terraform instead of technical debt 🎬 Watch on YouTube πŸ“ Blog Post πŸ’» GitHub Repository Hey Reader πŸ‘‹πŸ½ We've been heads-down the past weeks. Preparing the live AMA workshops from Black Friday (sorry for the delay!) and recording new YouTube videos. It's been a lot of fun. Speaking of videos - this week Tobi recorded one you'll want to watch. Here's the problem: LLMs want to close the...

AWS FOR THE REAL WORLD ⏱️ Reading time: 8 minutes 🎯 Main Learning: Generate AWS architecture diagrams using AI with Kiro and MCP servers - skip the hours of dragging boxes in Lucidchart. πŸ“ Blog Post 🎬 Watch on YouTube Hey Reader πŸ‘‹πŸ½ Big news: We launched our YouTube channel! 🎬 We've published 7 videos so far and are almost at 800 subscribers. Our goal is to keep a weekly rhythm, so expect fresh content every week. If you haven't subscribed yet, here's the link. No exciting AWS news this week....