D0mm
D0mm

Reputation: 170

Amazon Lambda with API Gateway vs Elastic Beanstalk for REST API

When is it better to use Eleastic Beanstalk instead of AWS Lambda + API Gateway?
For example: I have node.js medium-large size REST API application and do not know where should I deploy it. Both services look suitable, have auto-scaling and it makes me hard to decide. Cold start with JavaScript is not big and should not be a problem(unless app size has big impact).

I'm thinking about the setup and deploy. EBS has everything configured, but on the other hand, it doesn't look complex to attack API Gateway with Lambda.
I see that Lambda services are cheaper, but is it a good decision to have medium-large size REST app deployed on Lambda?
Any recommendations, experiences and insights?

Upvotes: 3

Views: 1160

Answers (1)

Ben Whaley
Ben Whaley

Reputation: 34406

Lambda vs Elastic Beanstalk is not really an apples-to-apples comparison.

With Lambda, you organize your application in to Functions. Functions are triggered by events, such as inbound HTTP requests from API Gateway. You must build your application to respond to these triggers and to run within the constraints of the Lambda execution environment. This is typically fine for an API, so long as you are willing to compose the application accordingly.

Elastic Beanstalk is more like a traditional computing environment where your application runs as a standalone, long-lived daemon that waits for requests from a load balancer. If your application is already written this way and you don’t want to refactor it to fit the Lambda function model, this is probably the easier path for you.

You might also consider packaging the application in to a container and running it with ECS Fargate. You’ll still benefit from a serverless environment, like Lambda, but you won’t need to refactor your application in to functions. It’s also considerably simpler than Elastic Beanstalk.

Side note: in AWS nomenclature, EBS is typically short for Elastic Block Store, a block storage service, as opposed to Elastic Beanstalk.

Upvotes: 5

Related Questions