简体   繁体   中英

AWS Lambda with Node.JS in production

I want to use Node.js in AWS Lambda in production. The question is how to make this reliable.

For me, reliability means:

  1. Retrying some parts of code - this exists from-the-box in AWS Lambda
  2. Exception notification - I tried Airbrake, but it does not work in AWS Lambda - process.on('uncaughtException') does not work
  3. Possibility to know if something is down and even exception notification does not work - in a usual app, I have the healthcheck endpoint.

So how can I implement 2 and 3 points?

One idea is using a SQS queue as a Dead Letter Queue , which can be set up for that lambda ( http://docs.aws.amazon.com/lambda/latest/dg/dlq.html ). So you can monitor that queue to analyze the inputs that made the function to fail and take some action.

For logging, you can use winston ( https://github.com/winstonjs/winston ). Works fine with AWS lambdas.

In your lambda workflow I guess you have some kind of error handler function where is anything happens, It ends there. You can use that error handler to send you emails with the event and context inputs and other error thingy descriptions.

Also you can monitor lambdas via cloudfront, and create an alarm that sends you certain data if somethign went wrong.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM