Hacker News new | ask | show | jobs
by ju-st 192 days ago
Would be interesting to add a cold start + "import boto3" benchmark for Python as importing boto3 takes forever on lambdas with little memory. For this scenario I only know this benchmark but it is from 2021 https://github.com/MauriceBrg/aws-blog.de-projects/tree/mast...
2 comments

I don't really use Python, but most AWS SDKs seem to be autogenerated for each language, and they're pretty much just thin wrappers over REST calls to interal AWS endpoints.

I dunno why a Python impl would be particularly heavy.

Sprawling imports of text source in hundreds of files without lazy loading.
if imports are slow one should probably look into pre-compiling .pyc files into the Lambda bundle
This is a well known issue, and the fix is not to create any boto3 clients at runtime. Instead, ensure they're created globally (even if you throw them away) as the work then gets done once during the init period. The init period gets additional CPU allocation, so this is essentially "free" CPU.

Source: I'm a former AWS employee.

Thanks for citing your sources, I think your source may be out if date, though! The “free init time hack” was killed in August (unless I’m missing something - never used it myself).

https://aws.amazon.com/blogs/compute/aws-lambda-standardizes...

Good callout that it's no longer free. However, you still get extra CPU, and assuming your execution environment isn't reloaded, that init time is amortized across all the invocations for the execution environment.

SnapStart is more widely available, which is the other option for shrinking the billed time spent in init (when I left, only Java SnapStart was available)