Skip to content

Run any server inside AWS Lambda. Simple translation layer for Lambda events to HTTP-like request. Work with Next, Apollo, Express, etc.

Notifications You must be signed in to change notification settings

sladg/lambda-server-adapter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWS Lambda Server Adapter

A tool to run web servers on AWS Lambda

It allows us to start server before events come in and we keep it running in the background as long as events are coming in. This reduces cold starts and improves performance.

Useful for applications such as NextJS, Graphql or REST servers, Express, Apollo, etc.

Features

  • Starts server before events come in and keeps it running in the background as long as events are coming in.
  • Translates AWS events into HTTP requests.
  • Translates HTTP responses into AWS events.
  • Simple plug-and-play as layer.
  • Small size, no dependencies, as fast as your server.

Usage

AWS Lambda Server Adapter work with native runtimes. It is added in a form of Layer.

NextJS

Lambda functions packaged as Zip package for AWS managed runtimes

Handler configuration

Readiness Check

Once new Lambda is started, it will initialize the runtime via Runtime API. We start server and wait for it to respond to our HTTP calls, once it does, we mark the Lambda as ready and start processing events.

In case server does not start - command fails, HTTP response is not received, etc. - we will log the error and Lambda will die after 10sec.

Configurations

Graceful Shutdown

Acknowledgement

This is a direct fork of AWS Lambda Web Adapter which was re-written and simplified. It's based on AWS's lambda_http.

About

Run any server inside AWS Lambda. Simple translation layer for Lambda events to HTTP-like request. Work with Next, Apollo, Express, etc.

Topics

Resources

Stars

Watchers

Forks