Testing the runtime difference between Python and Rust for AWS Lambda.
This repo contains two example Lambdas:
pythonLambda/— Python implementationrustLambda/— Rust implementation
The Lambdas are intended to be triggered by an S3 event. Note that an S3-triggered invocation can contain multiple records, so the handler typically loops over the incoming event records.
See the full write-up: https://www.confessionsofadataguy.com/aws-lambdas-python-vs-rust-performance-and-cost-savings/
At a high level, both Lambdas:
- Receive an S3 event
- For each record in the event, read the referenced object
- Perform the same workload in Python vs Rust
- Log timing information so the runtimes can be compared
(For exact details, see the implementation in each language folder.)
The Rust Lambda uses cargo-lambda to build and package the bootstrap binary required for deployment.
Install cargo-lambda (see the cargo-lambda docs for platform-specific instructions), then build the deployment zip:
cargo lambda build --release --output-format zip