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

AWS FOR THE REAL WORLD ⏱️ Reading time: 5 minutes 🎯 Main Learning: Deploy AWS's open-source TEAM solution for temporary admin access with approval workflows 🎬 Watch on YouTube Hey Reader πŸ‘‹πŸ½ I hope you had a great weekend and have a great week ahead. One thing I see over and over again in AWS setups: admin permissions are either handed out way too easily or way too hard. There is no middle ground. In other systems this was already solved. You shouldn’t have to DM somebody for admin access. We...

AWS FOR THE REAL WORLD ⏱️ Reading time: 12 minutes 🎯 Main Learning: Run an always-on AI agent on a $5 Lightsail instance with zero open ports, SSM access, and GitHub as a time machine for your agent's brain πŸ“ Blog Post 🎬 Watch on YouTube Hey Reader πŸ‘‹πŸ½ the past weeks there is obviously one driving topic: OpenClaw 🦞 We love seeing that a developer from our neighbor country πŸ‡¦πŸ‡Ή built a tool that got so MUCH hype. That is why we needed to try it out as well! While I (Sandro) added OpenClaw to my...