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: 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...

AWS FOR THE REAL WORLD ⏱️ Reading time: 4 minutes 🎯 Main Learning: Which AWS services are worth your time and which ones to skip 🎬 Watch on YouTube Hey Reader πŸ‘‹πŸ½ a new week, new AWS video coming out. I (Sandro) used all of my knowledge from the past six plus years building AWS solutions, ranking the services I actually use and the services I hate. For some I've changed my mind A LOT over the years (e.g. DynamoDB). Let me know what you think and check it out.Here you go AWS News But first of...

AWS FOR THE REAL WORLD ⏱️ Reading time: 12 minutes 🎯 Main Learning: The 11 most impactful AWS releases from the past 12 months that have nothing to do with AI. πŸ“ Blog Post Hey Reader πŸ‘‹ Every re:Invent recap, every AWS blog, every newsletter from the past year has been dominated by one topic. You know which one. But while everyone was writing about agents and foundation models, the core infrastructure layer kept moving. Quiet releases. No keynote fanfare. Things that actually affect your...