Can and should I use express.js in lambda?

0

Hello guys,

I'm currently planning a new project that will use lambda functions and Node.js as its runtime environment.

I have previously developed multiple lambdas using Node.js as my runtime but I never used express.

I'm well aware that:

  • Using just node is faster than using express.
  • Although using express is doable it is generally frowned upon.

Taking the points above into consideration along with the fact using express is a powerful framework. Is it still not worth using? Why? or why not? Can you please help and guide me through this? Are there any frameworks you would suggest ?

Note: It is also worth mentioning that multiple endpoints from the api gateway point to the same lambda

1 Answer
1
Accepted Answer

This stackoverflow posting covers the topic pretty well.
https://stackoverflow.com/questions/65266948/express-js-app-serverless-using-lambda-or-functions-a-good-idea

Key points are that lambda is best used to create single function microservices (one lambda == one function / microservice) which are small, fast and easy to maintain, test, deploy and troubleshoot. If you use a framework like express you are making one lambda into a full monolithic app and maintaining all the baggage of that architecture. If that is your plan, you are likely better off hosting in containers on ECS with Fargate or an multiple EC2 instances either of which should be fronted with an ALB for redundancy.

Hope this helps!

profile pictureAWS
EXPERT
iBehr
answered 21 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions