GithubHelp home page GithubHelp logo

nikodemeus / serverless-lambda-storage Goto Github PK

View Code? Open in Web Editor NEW

This project forked from leegilmorecode/serverless-lambda-storage

0.0 0.0 0.0 1.46 MB

An example of various serverless lambda storage options with benchmarks

License: MIT License

JavaScript 20.67% TypeScript 79.33%

serverless-lambda-storage's Introduction

Serverless Lambda Storage

Introduction

Practical examples of using lambda ephemeral temp storage, S3 and EFS as a comparison, utilising the Serverless Framework and TypeScript. Supporting repo for the blog post: Serverless lambda storage options 🚀

This blog post covers three options, with code examples; and discussions around when to use each, the advantages and disadvantages, and relative speed:

✔️ AWS S3

✔️ AWS EFS

✔️ Lambda Ephemeral Storage (tmp)

What are we building?

We are going to walk through building a solution which has an API with three endpoints to interact with each storage type via lambda, and just for fun we are working with images of Fortnite characters 😜

This will build out the following architecture:

architecture

Architecture Overview

  1. On deploy using the Serverless Framework we push the four Fortnite character images to an S3 bucket (Setup).
  2. On successful deploy we also use 'Hooks' to invoke a lambda which pushes the same images to EFS (Setup).
  3. The user can invoke any of the three endpoints for each storage type.
  4. The EFS based lambda is invoked via API Gateway and returns the files from EFS (EFS).
  5. The S3 based lambda is invoked via API Gateway and returns the files from S3 (S3).
  6. The tmp based lambda checks to see if the files reside in the /tmp folder on the lambda itself already, and if not, it caches the same files from S3. On subsequent invokes via API Gateway the files are there already in temp to serve from (TMP).
  7. All of the files are returned in base64 format. (the following website is great for viewing base64 strings as images: https://codebeautify.org/base64-to-image-converter)

more in depth descriptions of the code and architecture can be found in the blog post

The images which are returned from the API in base64 format are:

fortnite

credit for images above go to Fortnite & https://www.epicgames.com/fortnite/

Getting started

To get started, you can run the following commands from the root directory:

Note: This will incur costs in your AWS account which you should account for.

npm i

npm run deploy:develop

This will install the dependencies for the project and deploy the project to AWS.

To remove the project you can run: npm run remove:develop

Invoking the endpoints

Once deployed, you can invoke the three different endpoints using the postman file found here ./postman/

serverless-lambda-storage's People

Contributors

leegilmorecode 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.