Skip to content

fermiyon/aws-lambda-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWS Rust

By Selman Karaosmanoglu

Date created

8 July 2024

Rust Cargo-Lambda Deployment on AWS Lambda Serverless

Overview

This repository provides a guide for deploying a Rust-based AWS Lambda function on AWS Lambda utilizing Cargo-Lambda Rust library

Architecture

flowchart LR;
    A((HTTPS invoke)) <-.-> B((AWS Lambda λ));
    B <--> C[main.rs];
Loading

Key Advantages of Rust for AWS Lambda

  • Memory Efficiency: Rust uses significantly less memory compared to Python. This is because Rust is a compiled language with efficient memory management, while Python is an interpreted language with higher memory overhead.
  • Performance: Rust offers substantial performance improvements over Python, often ranging from 10 to 1000 times faster, depending on the task.
  • Deployment: Rust enables small binary deployments. By optimizing for size, Rust binaries can be significantly smaller than those of other languages.
  • Cost Efficiency: Building on ARM architecture can be up to 34% cheaper, especially with processors like Amazon’s Graviton.
  • Energy Efficiency: Rust is highly energy-efficient, often comparable to C, and significantly more efficient than languages like Python.
  • Fast Response Times: Rust can achieve very low response times, often as low as 2 milliseconds, due to its efficient execution and low-level control.

Getting Started

Install Rust

If you don't have Rust on your system install rust using https://rustup.rs

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Install Cargo lambda

Cargo Lambda simplifies running, building, and deploying Rust functions on AWS Lambda without needing containers or VMs.

brew tap cargo-lambda/cargo-lambda
brew install cargo-lambda

For more information or other installation information on Cargo Lambda: https://www.cargo-lambda.info/guide/getting-started.html

AWS CLI

Make sure AWS CLI installed and configured.

If not, you can install with pip

pip install awscli

Configure AWS

aws configure

Testing locally

Run the Rust app locally

make watch

alt text

Test locally

make invoke

alt text

Deploy to AWS

make build && make deploy

alt text

Test deployed app

make aws-invoke

alt text

Lambda Function Summary

alt text

Reference

  • Rust AWS Lambda - O'Reiily

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published