Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Too many require increase Lambda cold start time #61

Open
andreafalzetti opened this issue Jul 18, 2019 · 3 comments
Open

Too many require increase Lambda cold start time #61

andreafalzetti opened this issue Jul 18, 2019 · 3 comments

Comments

@andreafalzetti
Copy link

andreafalzetti commented Jul 18, 2019

Hey, first of all, thanks for your work on this module. It's a cool idea and very useful. I have been using this module and I've noticed increased Lambda cold start time simply by requiring this package. The cold start time was increased by over 500 ms so for an API it's quite high, I was wondering if it would be possible to refactor a bit and get rid of full lodash and aws-sdk require which slow things down?

https://github.com/baseprime/dynamodb/blob/master/lib/index.js#L3

Results of my tests, first one without dynamodb

{
  "datapoints": 9,
  "average": 235.77777777777777,
  "min": 227,
  "max": 247.3,
  "median": 239.7,
  "rawData": "227,228.4,229.7,232.7,236,239.7,240.3,240.9,247.3"
}

with dynamodb

{
  "datapoints": 9,
  "average": 863.5666666666666,
  "min": 790.8,
  "max": 925.8,
  "median": 880.5,
  "rawData": "790.8,828.9,836.5,861.2,867.7,880.5,880.5,900.2,925.8"
}

ColdStart time was increased from ~250ms to ~900ms

Here, a good read about cost of requiring the full aws-sdk: https://theburningmonk.com/2019/03/just-how-expensive-is-the-full-aws-sdk/

@fuschini
Copy link

Hi @andreafalzetti
Have you tried setting up a Lambda Layer with this module in it? This way your function itself gets smaller and can start in less time while the layer is only plugged with the function is ready.

@andreafalzetti
Copy link
Author

@fuschini I am not sure that will help, at runtime this module requires the aws-sdk module which is loaded in memory - How is the Layer helping that? We are not talking about bundle size.

@tfrancois
Copy link

Respectfully, I thought the whole idea behind the module was the idea that it would NOT require aws-sdk as a dependency. When I tried to add it this library to my project, it now lists the aws-sdk as required. Is this a mistake? Thanks.

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

No branches or pull requests

3 participants