Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@theapexlab/serverless-icebreaker
Advanced tools
Check your lambdas file size and optimize them to reduce cold start duration.
The serverless Icebreaker is a utility designed to analyze pre-built AWS Lambdas and mitigate cold start duration. Cold start duration can result in user experience issues, such as lengthy page loading times. By optimizing the size of the lambda build, you can reduce cold start duration and improve overall performance.
Lambda Size Analysis
: The Serverless Icebreaker examines the file size of AWS Lambdas and identifies if the build is not compacted.Library Usage
: It identifies the three most frequently utilized or imported libraries in the Lambda function.Metrics Generation
: The tool generates metrics for all analyzed Lambdas, allowing you to monitor their sizes and track improvements over time.Threshold Errors
: If a Lambda's size exceeds a specified threshold, the tool generates an error, indicating the need for optimization.Framework Optimization
: The default configuration of the Serverless Icebreaker is optimized for the SST and Serverless frameworks, making it easy to integrate and use within your projects.The chart illustrates the correlation between lambda build size and cold start duration. As the lambda build size increases, the cold start duration also tends to be longer. This relationship highlights the importance of optimizing the lambda build size to reduce cold start latency and enhance overall performance.
Our mission is to minimize cold start duration and improve user experience. One of the most effective practices we recommend is optimizing your lambda build size
Lambda build size | Cold start duration |
---|---|
1 MB | 150 ms |
19.6 MB | 692 ms |
30.2 MB | 1716 ms |
52.8 MB | 2515 ms |
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)
SUCCESS
/ The lambda build size is lower than the error thresholdWARNING
/ The lambda build size is within 10% of the error thresholdERROR
/ The lambda build size is higher than error thresholdnpm install @theapexlab/serverless-icebreaker --save-dev
npx sib
or
npm run sib
npm uninstall @theapexlab/serverless-icebreaker
Upon first run, it creates a sib-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 sib-config.json
) the developer gets an error, and the three most used libs in the lambda.
The configuration file sib-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 locatederrorThresholdMB
: the maximum acceptable size of the lambda in megabytesshowOnlyErrors
: show only the files that exceed the error thresholdfilterByName
: search filter for filesignorePattern
: term, either complete or partial, to exclude from file namesdetailedReport
: gives you a detailed report and the endSearch for something specific in a lambda's name:
npx sib --filterByName=get
Add string to ignore in file names:
npx sib --ignore-pattern=redis
Overwrite the error threshold:
npx sib --errorThresholdMB=30
To show only the files that exceed the error threshold:
npx sib --showOnlyErrors
To run a detailed report:
npx sib --detailed-report
To see all available options:
npx sib --help
When using the --pipeline flag, (a sib-config.json configuration file is required). In the absence of any errors, no output will be generated. However, if an error does occur, the program will exit with code 1.
This feature allows you to seamlessly integrate it into your existing pipeline, such as Husky or GitHub Actions, for efficient error handling and continuous integration.
For optimal results it is advisable to perform a build before very run.
npx sib --pipeline
or
npm run sib --pipeline
npx husky add .husky/pre-commit "npm run sib --pipeline"
jobs:
...
steps:
...
- name: sib
run: npm run sib --pipeline
If you have any questions or need clarification about SIB, feel free to ask in the repository. Other community members and maintainers can provide insights, solutions, and guidance to help you out.
Encountered an error or facing an issue with SIB? Make sure to create a bug report. By reporting bugs, you contribute to the improvement of the tool and help the maintainers identify and address any problems.
Have a brilliant idea for a new feature or enhancement in SIB? Submit a feature request to share your suggestions with the community. It's an opportunity to shape the future of the tool and contribute to its growth.
We are digital product experts with a vision of delivering top-quality solutions focusing on serverless.
FAQs
Check your lambdas file size and optimize them to reduce cold start duration.
We found that @theapexlab/serverless-icebreaker demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.