Giter Site home page Giter Site logo

tkahng / serverless-rust-demo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aws-samples/serverless-rust-demo

0.0 0.0 0.0 294 KB

Sample serverless application written in Rust

License: MIT No Attribution

JavaScript 1.42% Rust 96.70% Makefile 1.88%

serverless-rust-demo's Introduction

Serverless Rust Demo

build

Architecture diagram

This is a simple serverless application built in Rust. It consists of an API Gateway backed by four Lambda functions and a DynamoDB table for storage.

This single crate will create five different binaries, one for each Lambda function. It uses an hexagonal architecture pattern to decouple the entry points, from the main domain logic, the storage component, and the event bus component.

๐Ÿ—๏ธ Deployment and testing

Requirements

  • Rust 1.56.0 or higher
  • cargo-lambda
  • Zig for cross-compilation (cargo-lambda will prompt you to install it if it's missing in your host system)
  • The AWS SAM CLI 1.33.0 or higher for deploying to the cloud
  • Artillery for load-testing the application

Commands

You can use the following commands at the root of this repository to test, build, and deploy this project:

# Optional: check if tools are installed
make setup

# Run unit tests
make tests-unit

# Compile and prepare Lambda functions
make build

# Deploy the functions on AWS
make deploy

# Run integration tests against the API in the cloud
make tests-integ

Load Test

Artillery is used to make 300 requests / second for 10 minutes to our API endpoints. You can run this with the following command:

make tests-load

CloudWatch Logs Insights

Using this CloudWatch Logs Insights query you can analyse the latency of the requests made to the Lambda functions.

The query separates cold starts from other requests and then gives you p50, p90 and p99 percentiles.

filter @type="REPORT"
| fields greatest(@initDuration, 0) + @duration as duration, ispresent(@initDuration) as coldStart
| stats count(*) as count, pct(duration, 50) as p50, pct(duration, 90) as p90, pct(duration, 99) as p99, max(duration) as max by coldStart

Load Test Results

๐Ÿฆ€ Getting started with Rust on Lambda

If you want to get started with Rust on Lambda, you can use these cookiecutter templates to setup your project.

๐Ÿ‘€ With other languages

You can find implementations of this project in other languages here:

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

serverless-rust-demo's People

Contributors

nmoutschen avatar mbergkvist avatar hffmnn avatar calavera avatar brainstorm avatar amazon-auto avatar jeastham1993 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.