Skip to content

Conversation

perpil
Copy link
Contributor

@perpil perpil commented Nov 25, 2023

This lazy loads the S3 client so it no longer adds ~100 ms to coldstarts if you minify your bundle and don't use S3. If you are using the on disk version of client-s3, it reduces coldstarts by ~300ms. By lazy loading you can also omit client-s3 in a minified bundle if you don't use it reducing the bundled package size by over 340 KB. While making this change I noticed that the call to setConfig when using a custom s3 client was in the run method causing a new S3Client to be created for every request. I moved the setConfig call to the createAPI method so the same S3 client is reused across requests.

Copy link
Collaborator

@naorpeled naorpeled left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
Thanks for this, you rock!

@naorpeled naorpeled merged commit 56a4cff into jeremydaly:main Nov 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants