Skip to content
Episode #69: Optimizing your Lambda Functions with Alex Casalboni (PART 2) episode artwork

Oct 5, 2020 40 min

Episode #69: Optimizing your Lambda Functions with Alex Casalboni (PART 2)

from Serverless Chats Hosted by Jeremy Daly & Rebecca Marshburn

About Alex Casalboni Alex Casalboni has been building web products and helping other builders learn from his experience since 2011. He’s currently a Senior Technical Evangelist at Amazon Web Services, based in Italy, and as part of his role, often speaks at technical conferences across the world, supports developer communities and helps them build applications in the cloud. Alex has been contributing to open-source projects such as AWS Lambda Power Tuning, and co-organizes the serverless meetup in Milan, as well as ServerlessDays Milan (previously JeffConf). He is particularly interested in serverless architectures, ML, and data analytics. Twitter: https://twitter.com/alex_casalboni LinkedIn: https://www.linkedin.com/in/alexcasalboni/ Website: https://alexcasalboni.com/ Dev.to: https://dev.to/alexcasalboni Medium: https://medium.com/@alexcasalboni AWS Lambda Power Tuning Project: https://github.com/alexcasalboni/aws-lambda-power-tuning Deep dive: finding the optimal resources allocation for your Lambda functions: https://dev.to/aws/deep-dive-finding-the-optimal-resources-allocation-for-your-lambda-functions-35a6 Test Functions/Patterns for Power Tuner: https://gist.github.com/alexcasalboni/9ce2cef56a7d052d4f5e798b37083525 Watch this episode on YouTube: https://youtu.be/m2NB_0J5fms Transcript Jeremy: if we go back to the sort of the having to run this on every function, and you maybe make a change to a function, you do something like that, it just becomes very, very tedious, and probably a lot of work to run this on every single function. But as you start to see... You run it on a few functions, maybe different types of workloads, those patterns start to emerge, right? Alex: Absolutely. There is not an infinite set of patterns. I have identified about six or seven. Usually, you end up in some of these. There are other patterns where the output is a bit randomic meaning there is either some downstream dependency that is not scaling as well as Lambda is. So you might see some noise in the data. But yeah, usually you end up in one of these categories. I think there is a last category that is a bit spatial where you actually are downloading or uploading a lot of data. I've seen this with S3 maybe you need to download 50 or 100 megabytes of data from S3. I wouldn't recommend you. But if you really have to do that the power tuning implications are very interesting, in my opinion, because if you also change one line of code, and I did this experiment with Python. So, it was pretty easy. I think you can do also the same with Node or Java or other SDKs. So, if you enable the multi threading options in the SDK especially at a high power like above 1.8 gigabytes you get two cores. And so, you just start downloading or uploading using 10 or 20 threads, you actually see a massive difference there. So, you might see 10% improvement for cheaper cost. So, if that's what you're doing with Lambda, you might consider full power. But again, check the numbers. Jeremy: Right. And the other thing too is, again, knowing... You mentioned Python, knowing your runtime is important because node is single threaded. So, even if you do go over the 1.8, you do not get a second core because Node doesn't work that way. All right. So, you mentioned something really interesting. I think this is another fascinating thing about pay per use services is Lambda has a 100 millisecond billing model. So, if you run something for 99 milliseconds you pay for 100 milliseconds. If you run something for 101 milliseconds you pay for 200 milliseconds. So, I think an important piece of this, if you are trying to optimize for cost, is also understanding that billing rounding thing, right? Alex: Yeah, that's true. I've been talking to some development teams. And it's very common that you develop a service application, and you end up as you were saying with 10, or 50, or 100 functions. And one day the manager wakes up and wants to optimize for cost or for performance. And you're like, sure, but where do I start? I have 100 functions. But I think it's also important to know what your functions are doing to detect the right pattern and to know where it makes sense to optimize. There are cases where your team or yourself or your manager may want to only optimize for cost. It's a cost optimization project, whatsoever. And you might end up optimizing some functions where there is no way that you can actually shave off enough milliseconds to go down one level, 100 millisecond level. So, maybe you're just optimizing for the user experience, which is great. Or maybe it's not a customer facing app, so it doesn't matter. But I think it makes sense to understand how cost and performance are related in serverless. Because sometimes they are aligned to each other, meaning you can optimize for both just in one shot. But you still want to be aware, especially if it's about prioritizing between a large set of functions. Actually, I got that feedback a lot. I think if I see a direction of Lambda Power Tuning evolving into something that would help a development team handle multiple functions I'll build something like a prioritizer error or something that helps you detect those kind of functions more easily or to help you with a batch of functions, for example. Jeremy: Right. Yeah, no, I think that'd be another very cool project. I think you asked the right question there. And then at least, this is something for me is sort of what are you optimizing for? Are we trying to make the user experience better, so we have lower latencies? Are we trying to get the cost down on the backend, maybe for running ETL tasks and things like that? Those are certainly things where I think this comes in. Really, this is an important thing to consider is to say, "Are we trying to save 10 bucks a month from our front end just so that we're, again, saving $10 a month, but maybe it takes 120 milliseconds for our API to respond. Or are we trying to save potentially thousands of dollars on the backend if we're running these complex ETL tasks. And that brings me to something... So, Joe Emison who runs Branch Insurance, every month he usually post a screenshot of his bill. And running an entire online insurance agency his Lambda bill was $22.65. So is optimizing for cost in that situation something that should even cross your mind? Alex: Yeah, that's a fair question. It probably isn't. I would still suggest you run Lambda Power Tuning because you might be willing to pay $26, and get a 30% performance improvement. So, it's not like one or the other depending on your scale, depending on the use case, depending on the customer needs you might decide to invest on performance. And with Lambda it's pretty simple. You can visualize it. You have one knob, and it's fairly simple. So, as I was saying, it's almost free to run this power tuning process. I've seen customers who actually run ...

Episode details come from the podcast's RSS feed.

Embed this episode

In the conclusion of this two part episode, Jeremy chats with Alex Casalboni about strategies to optimize Lambda functions, how to use his AWS Lambda Power Tuning project to find the right balance of cost and performance, and how to combine Lambda with other AWS services to maximize the power of each execution.

Ready to play

Episode #69: Optimizing your Lambda Functions with Alex Casalboni (PART 2)

0:00 40:24

No transcript yet.

Requests help us decide what to transcribe next.

Evolving with Georgia May Georgia May Change is the only constant. Evolving explores the beauty and uncertainty of self-discovery. This podcast is a space for learning and unlearning, shedding old layers, leaping into transformation and embracing the unknown. There is no final destination. This show is for those who are committed to the lifelong journey of discovery; it's time to reinvent yourself, while simultaneously returning to who you’ve always been. Note: This podcast was previously known as Life Chats, where well-known and everyday individuals shared their real life stories, hosted by journalist Georgia May. Enjoy the catalogue of inspiring episodes! Autistic Voices Evalynne Charmer - Autistic Voices Autistic Voices is an authentic and insightful podcast series that explores the world of autism and neurodiversity through the voices of those who know it best - autistic individuals. Join therapist and fellow autist, Evalynne Charmer, as she chats with guests about their experiences with autism and rethinks common misconceptions about neurodiversity. From challenges to triumphs, each episode of Autistic Voices provides a unique perspective on autistic lives. Tune in now to hear these authentic autistic voices! Choosing Change Podcast Lizzie Moult The Choosing Change podcast reveals our greatest life lessons and the small adjustments we make that have a big impact on our life. Hosted by Lizzie Moult, an Aussie cognitive behavioural therapist living in the Scottish Highlands. She chats with incredible people who share their challenges and personal experiences. Whether you're looking for a boost of inspiration, or practical tips to help you create a more fulfilling life, the Choosing Change podcast has something for you. It's your choice, ordinary or extraordinary.#choosingchangepodastwww.choosingchangepodcast.co.ukwww.lizziemoult.com/podcast

Frequently asked questions

How long is this episode of Serverless Chats?

This episode is 40 minutes long.

When was this Serverless Chats episode published?

This episode was published on October 5, 2020.

Can I download this Serverless Chats episode?

Yes. Use the download control on the episode player to save the publisher-provided media file.