Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/exoego/cold-stat
statistically analyze cold start of Lambda functions
https://github.com/exoego/cold-stat
aws-lambda lambda-functions performance-testing
Last synced: 3 months ago
JSON representation
statistically analyze cold start of Lambda functions
- Host: GitHub
- URL: https://github.com/exoego/cold-stat
- Owner: exoego
- License: mit
- Created: 2024-03-21T09:35:18.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-07-24T02:53:13.000Z (6 months ago)
- Last Synced: 2024-10-06T03:58:32.094Z (3 months ago)
- Topics: aws-lambda, lambda-functions, performance-testing
- Language: Rust
- Homepage:
- Size: 58.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cold-stat
[![Crates.io Version](https://img.shields.io/crates/v/cold-stat)](https://crates.io/crates/cold-stat)
A CLI tool to statically analyze the initialization time, known as cold-start, of AWS Lambda functions.
## Prerequisites
- Rust toolchain is required to install the tool
- AWS credential is required to access AWS
- Following actions must be granted in IAM policy
- `lambda:GetFunctionConfiguration` to fetch the current env vars of the function
- `Lambda.UpdateFunctionConfiguration` to update the env vars of the function, to force cold-start
- `lambda:InvokeFunction` to invoke tha function
- `logs:StartQuery` to query CloudWatch Logs for cold start analysis## Installation
```bash
cargo install cold-stat
```## Usage
```
cold-stat [OPTIONS] --function --payload# Example
cold-stat --verbose --function=YOUR-FUNC-NAME --iterations=300 \
--payload='{"foo": "bar"}'
```### Options:
- `-f`, `--function `
- Name or ARN of function to invoke
- `-p`, `--payload `
- JSON payload to send to the function
- `--log-group-name `
- Name of CloudWatch log group to analyze
- [default: `/aws/lambda/FUNCTION`]
- `--log-stream-filter `
- Regex to filter CloudWatch log group stream. Useful when log group is shared by multiple functions
- [example: `/YOUR-FUNCTION-NAME/`] when log streams are named like `2021/01/01/YOUR-FUNCTION-NAME[$LATEST]`
- `-i`, `--iterations `
- Number of iterations to invoke the function
- It is recommended to set `30` at least. Because the number of collected cold starts often is a bit shorter than the specified `ITERATIONS` due to eventual consistency of CloudWatch Logs
- [default: `100`]
- `-v`, `--verbose`
- Print debug logs if enabled
- `-h`, `--help`
- Print help
- `-V`, `--version`
- Print version### Result
- `mem`
- Memory size of the function
- `count`
- Number of cold starts collected
- `stddev`, `min`, `max`
- Standard deviation, minimum, and maximum of cold start time respectively
- `p50`, `p90`, `p95`, `p99`, `p995`, `p999`
- Percentiles of cold start time
- For example, `p50` is 50 percentile, also known as the median
- `p995` and `p999` are 99.5 and 99.9 percentiles, respectively## Development
### Build
```bash
git clone https://github.com/exoego/cold-stat
cd cold-stat
cargo build
```### Run
```bash
cargo run -- \
--function=YOUR-FUNC-NAME \
--iterations=10 \
--verbose \
--payload='{"foo": "bar"}'
```## Acknowledgement
- This tool is highly inspired by [lumigo-io/SAR-measure-cold-start](https://github.com/lumigo-io/SAR-measure-cold-start)