Skip to content

Too many require increase Lambda cold start time #61

Open
@andreafalzetti

Description

@andreafalzetti

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/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions