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: 10 minutes 🎯 Main Learning: S3 Files gives POSIX access at S3 prices: 13x cheaper than EFS for large files, but the 60-second write-back delay silently breaks coordination patterns! πŸ“ Blog Post πŸ’» GitHub Repository 🎬 Watch on YouTube Hey Reader πŸ‘‹πŸ½ Sandro is currently traveling through Portugal - work and fun combined! If you happen to be around, reach out. Would be great to meet up! 🀝 This week we're digging into S3 Files: a POSIX file system backed by...

AWS FOR THE REAL WORLD ⏱️ Reading time: 6 minutes 🎯 Main Learning: 5 common AWS account mistakes and how to fix each one in under 10 minutes 🎬 Watch on YouTube Hey Reader πŸ‘‹πŸ½ New week, new AWS deep dive 🐠 In this one, we'll show you the 5 most common mistakes we've seen in almost every AWS account we've looked at. Yes, there are more out there. But these are the ones you'll see everywhere. And they're pretty simple to fix! The good news? Most of these fixes take under 10 minutes. Rather watch...

AWS FOR THE REAL WORLD ⏱️ Reading time: 9 minutes 🎯 Main Learning: Build a self-service portal that grants temporary AWS + Azure access and revokes it automatically β€” using Kestra and one YAML file. πŸ“ Blog Post πŸ’» GitHub Repository 🎬 Watch on YouTube Hey Reader πŸ‘‹πŸ½ Happy new week! Tobi and I met up last week and spent some time planning the videos ahead. We’re going more and more into YouTube β€” and a few things I’m hyped about: The biggest AWS mistakes we’ve made (so you don’t have to) How...