@attila.danku/cold-start-tool v1.1.5
❄️ 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

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-devRun:
npm run cstUninstall:
npm uninstall @theapexlab/cold-start-toolBehind 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 locatedsearchTerm: the start of the node_module comments to findwarningThresholdMB: the maximum acceptable size of the lambda in megabytesshowOnlyErrors: show only the files that exceed the warning thresholdfilterByName: searchfilter for filesdetailedReport: gives you a detailed report and the end
Custom arguments
Search for something specific in a lambda's name:
npm run cst --filterByName=getOverwrite the warning threshold:
npm run cst --warningThresholdMB=30To show only the files that exceed the warning threshold:
npm run cst --showOnlyErrorsTo run a detailed report:
npm run cst --detailed-reportTo see all available options:
npm run cst --help