Custom Software Apps & SharePoint Consulting

AWS Lambda vs. Elastic Beanstalk

AWS Lambda vs. Elastic Beanstalk

AWS Lambda vs Elastic Beanstalk

You’re contemplating a software migration from your own servers to cloud hosting. There are many ways to do it, with varying options. This article looks at two of them from Amazon Web Services: Lambda and Elastic Beanstalk. Both are great choices, but they serve different purposes. Lambda is simpler and less expensive, while Elastic Beanstalk lets you run full applications and gives you control over their environment. Understanding each one’s strengths will let you make an informed choice between these AWS services.

What is Elastic Beanstalk?

With Elastic Beanstalk, you have access to a Platform as a Service (PaaS), and you can manage some aspects of the infrastructure. Developers can create, test, and deploy applications on the platform. You don’t have to deal with provisioning, load balancing, or scaling. Elastic Beanstalk supports many server environments, including Apache HTTP Server, Nginx, Microsoft IIS, and Apache Tomcat. It has strong support for Docker containers, allowing easy deployment of applications.

Developers can use either the command line or the Elastic Beanstalk Management Console. The console lets them set up configurations and manage environments and applications.

What is Lambda?

Developers uploading to Lambda don’t have to deal with their code’s environment. It’s a “serverless” service which lets outside code or events invoke functions. Lambda doesn’t store data, but it allows access to other services which do. The thing which really makes Lambda attractive is that you pay nothing except when you actually run code on it. You can pull compute-heavy pieces out of your applications and deploy them on Lambda for a very low cost.

You can’t run full-blown applications on Lambda, but AWS Step Functions implement a state machine, letting you invoke a series of Lambda functions and handle error conditions. Lambda functions can serve as a backend to an application running elsewhere.

Take a look at our introduction to Lambda for more details on why it might be just what you need.

 

Pricing

If you can do what you need with Lambda, it’s a lot less expensive than Elastic Beanstalk. AWS Lambda pricing starts with a million free requests a month, up to a maximum of 400,000 GB-seconds. That’s not just part of the 12-month Free Tier term but is available indefinitely. Each addition

al million requests cost $0.20, plus $0.00001667 per GB-second. There’s no cost for keeping your code on AWS when it isn’t being called.

If you need other services, such as S3 storage or databases, they carry a cost on top of Lambda.

Elastic Beanstalk pricing is more complicated. There’s no charge for using Elastic Beanstalk as such, but you pay for the AWS resources that store and run your code. The Free Usage Tier, which is available for 12 months, may be enough to run many applications that don’t get heavy traffic.

Applications will usually run on EC2, which is where you pay for instances, load balancing, and data transfers. You can pay for on-demand, reserved, or spot instances, or you can request a dedicated server. On-demand works best if your requirements vary over time, and spot instances can save money if you’re flexible about when your applications run.

How much an instance costs depends on how much power you need. At the low end, one t3.nano instance costs $0.0052 per hour under on-demand pricing. The high end can run over $24 per hour. Incoming data transfers are free, but outgoing data on the Internet after the first gigabyte costs $0.09 per GB, with lower gigabyte rates for more than 10 TB.

With so many options, price comparisons are difficult. You can consistently expect to pay less for Lambda, though, if you can do the same thing on both platforms.

Use Cases

Lambda lets you define functions which are available at any time, but it doesn’t give you any persistent storage or state information. This isn’t as limiting as it may sound, though. You can add S3 storage or a database as a backend. You can offload processing tasks from a front-end application onto Lambda. AWS Step Functions allow the implementation of simple workflows. Amazon API gateway provides a backplane for building an API using Lambda functions.

You can even use Elastic Beanstalk and Lambda together. A lightweight application on EC2, managed with Elastic Beanstalk, can use Lambda for its heavy-duty processing. The application could run on a low-priced instance, and the costs of Lambda will be significantly less than the higher-end instances that would otherwise be necessary.

Lambda does have some hard limits. The request body payload can’t be more than 6 MB. The duration of a request can’t exceed 300 seconds. This makes it unsuitable for passing large blocks of data or for functions that wait a long time, but there are often workarounds.

There are also deployment limits; a deployment package can’t exceed 50 MB. Lambda code can include existing libraries, but very large libraries could be a problem.

An application platform such as Elastic Beanstalk is necessary for running a service which listens on an Internet port, such as a Web application. The code on Lambda may do the bulk of the work, but it can’t run the application itself.

If customization of the application’s environment is necessary, Elastic Beanstalk offers a lot of value. Anything that’s concerned with the details of security, resource allocation, auto-scaling, and log customization needs more flexibility than Lambda offers.

The Bottom Line

When you’re deploying a “real” application — one that keeps persistent information in files and responds to queries over the Internet — you need an application platform. When you just need to implement an API, Lambda is likely to be the most economical way to do it. It can provide a backend to almost any kind of software.

The whole application doesn’t need to be on the application platform. A hybrid approach, with functions on Lambda doing the bulk of the computing, will let you run a lightweight application that doesn’t require a huge amount of server power. When making the choice of AWS Lambda vs. Elastic Beanstalk, it isn’t necessarily an either-or choice.

Don’t forget to sign up for our AWS Newsletter to keep up on all the latest features and options.

Share this post with your friends

Skip to content