oslabs-beta / LatenSee

Improve first-run latency and visualize the latency of serverless function invocations

Home Page:https://www.latensee.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LatenSee

Improve first-run latency and visualize the latency of server-less function invocations.


Features

LatenSee is a light application which will consistently ping your Lambda functions keeping them warm, and thus providing a faster client experience for your end-users. Point LatenSee to your functions, select an invocation rate and LatenSee will take care of the rest!

Performance at a glance

See all your function's latency from recent invocations and stats about your app's Lambdas

Warm any lambdas

Easily add new endpoints to LatenSee and instantly start keeping them warm

Granular Control

Organize Lambdas into different apps and control invocations uniquely for each function.


How to use LatenSee

Update your Lambda functions to recognize LatenSee's pings:

In your Lambda functions, add these two lines surrounding function's declaration:

+ let cold=true;
export const handler = async (event) => {
+   if(event.body==='LatenSee'){const body={cold};cold=false;return{statusCode:200,body:JSON.stringify(body)};}cold=false;

  /**
   * Retain all other Lambda Functionality here
   */
  return { statusCode: 200, body: JSON.stringify('Lambda complete') };
};

See below for an explanation of the snippet:

// Declare varible to flag when this is a cold start
let cold = true;

export const handler = async (event) => {
  // If the request is coming from LatenSee, then process it first
  if (event.body === 'LatenSee') {
    // Save status of cold when function runs
    const body = { cold };
    // Set cold to false since we have now run it
    cold = false;
    // return with the cold status
    return { statusCode: 200, body: JSON.stringify(body) };
  }
  // for all other functionality, set cold to false since we have warmed this function
  cold = false;

  /**
   * Retain all other Lambda Functionality here
   */
  return { statusCode: 200, body: JSON.stringify('Lambda complete') };
};

Build LatenSee locally and then create a docker image

npm run build
docker build -t latensee-image .

Deploy your docker image alongside your production lambdas

For a sample guide, you can follow our high-level proof of concept walkthrough here.


Contributors

Team Member LinkedIn Github
Stephen Chow
Reem Abi Ammar
Emma Ijiogbe
Evan Griffith

If you found this interesting or helpful, feel free to drop a star on this project!

You can contribute by:

  • Raising issues you find in GitHub Issues
  • Fixing issues by opening pull requests
  • Improving documentation

In order to run the test suite, you can use the following:

npm install
npm run test

License

LatenSee is distributed under the MIT License.

About

Improve first-run latency and visualize the latency of serverless function invocations

https://www.latensee.com/


Languages

Language:JavaScript 86.2%Language:SCSS 11.9%Language:HTML 1.7%Language:Dockerfile 0.1%