bookmark_borderRecipe: Reducing cold start with precompiled python bytecode in serverless

Scroll to the bottom if you want the recipe and skip story telling.

This is a story of software: You have a greenfield project. It’s beautiful and fast. Then you add features. For five years. Then you realize your cold start times went from ~1 second to ~5.5 seconds.

To be fair, a ton of things happened in between and I did realize that cold start time had gone up like crazy. Some mitigating steps were taken to “control” them. Although, my local tests had always shown that precompiling bytecode was the best way to improve cold start, I never managed to make it work into production. Despite the precompilation, it kept being slow.

Then comes the AI and spare time. And the conversation basically goes like

🧑‍🦱Me: Hey AI! I see improvements to cold start locally when I precompile my python bytecode. I don’t see it when it’s in production. I use the serverless framework. Can you tell what’s going on?

Continue reading “Recipe: Reducing cold start with precompiled python bytecode in serverless”

bookmark_borderMeasuring Sentry Impact on AWS Lambda Cold Start and Time to Handler

At Local Logic, we rely heavily on lambda functions. We currently monitor our environment with Sentry via their sdk and know that we could use, as an alternative, the sentry layer. As a good developer, I wondered what were the pros and cons. Obviously, one of them is: which option is the fastest? So, I compared them and will share the results in this post. Without further introduction, let’s dig into the experiment.

Continue reading “Measuring Sentry Impact on AWS Lambda Cold Start and Time to Handler”

bookmark_borderServerless: How to share the ids of an existing API Gateway

The serverless documentation indicates how to share the ids of an API Gateway, but the technique described there seems to work only for a new deployment. (In my case, following this technique created a 2nd empty API Gateway whose ids were shared, which was, unsurprisingly, not fulfilling my needs).

Here is how to do it for an existing deployment.

Continue reading “Serverless: How to share the ids of an existing API Gateway”

bookmark_borderMinimize the size of lambdas by deleting boto3 from the deployment package

Last April, I wrote a post about managing boto3 in deployed packages. (See Minimizing the size of lambdas by avoiding having boto3 and its stubs in the deployment package). This approach works when all dependencies can be set in the development section.

But, what about when dependencies are required in production? For example, we recently had to deploy a lambda that depends on awswrangler. So the technique suggested in the previous post did not work. Here I will cover a different approach that allows to remove boto3 from the package to be deployed in the example context. It is however less flexible and based on a specific technology: serverless.

Continue reading “Minimize the size of lambdas by deleting boto3 from the deployment package”