1.1.5 • Published 11 months ago

@attila.danku/cold-start-tool v1.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

❄️ Cold start tool ❄️

Introduction:


This tool is designed to analyze built AWS Lambdas. It can check the file size of the Lambdas and, if the build is not minified, it can identify the three most used/imported libraries in the Lambda function and also creates metrics about all of the Lambdas. If the size of the Lambda exceeds a specified threshold, a warning will be generated. Our default config is optimized for SST framework.

About cold start duration

npm.io

Here some examples how to optimize your lambda imports:

// Instead of const AWS = require('aws-sdk'), use:
const DynamoDB = require('aws-sdk/clients/dynamodb')

// Instead of const AWSXRay = require('aws-xray-sdk'), use:
const AWSXRay = require('aws-xray-sdk-core')

// Instead of const AWS = AWSXRay.captureAWS(require('aws-sdk')), use:
const dynamodb = new DynamoDB.DocumentClient()
AWSXRay.captureAWSClient(dynamodb.service)

Usage


Installation:

npm install @theapexlab/cold-start-tool --save-dev

Run:

npm run cst

Uninstall:

npm uninstall @theapexlab/cold-start-tool

Behind the scenes


Upon first run, it creates a cst-config.json with the default settings for SST in the root of the project.

If the lambda is not minified on build time the imported node-modules are commented like this // node_modules/... , so this app basically counts the occurrences of the same imports, and if the file size is over 20MB (can be changed in cst-config.json) the developer gets a warning, and the three most used libs in the lambda.

Configuration


The configuration file cst-config.json can be found at the root of the project. Here you can change a few things:

  • buildPath: default folder where the built lambdas are located
  • searchTerm: the start of the node_module comments to find
  • warningThresholdMB: the maximum acceptable size of the lambda in megabytes
  • showOnlyErrors: show only the files that exceed the warning threshold
  • filterByName: searchfilter for files
  • detailedReport: gives you a detailed report and the end

Custom arguments


Search for something specific in a lambda's name:

npm run cst --filterByName=get

Overwrite the warning threshold:

npm run cst --warningThresholdMB=30

To show only the files that exceed the warning threshold:

npm run cst --showOnlyErrors

To run a detailed report:

npm run cst --detailed-report

To see all available options:

npm run cst --help
1.1.5

11 months ago

1.1.4

11 months ago

1.1.3

11 months ago

1.1.2

11 months ago

1.1.1

11 months ago

1.1.0

11 months ago

1.0.9

11 months ago

1.0.8

11 months ago

1.0.7

11 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago