Q
Get started Bring yourself up to speed with our introductory content.

When should we use Lambda functions as an EC2 alternative?

Lambda functions have been helpful to respond to events within AWS, but under what circumstances can our enterprise use the service to replace EC2 instances?

AWS Lambda is a service for running code in response to events in the AWS environment. AWS Lambda is a platform...

as a service-like product. It manages the provisioning of virtual servers to run your code.

For example, as part of a data load operation, an extract, transform, load process might write data to an Amazon Simple Storage Service (S3) bucket. That write event triggers the execution of a Lambda function, which performs a series of checks on the uploaded object and loads the data into a Relational Database Service (RDS) table. Lambda can respond to events from several Amazon Web Services (AWS) products, including DynamoDB, S3, Simple Email Service, Simple Notification Service, Kinesis and Cognito.

Lambda users do not need to patch or worry about instance-level security issues. With the service, AWS also manages scaling and reliability. Lambda is well-suited to run applications written in one of the supported languages, including Node.js, Python and Java.

So when is it beneficial to replace Elastic Compute Cloud (EC2) instances with Lambda functions? There are a few considerations:

Is the developer's code designed to execute in response to events in AWS? If so, then Lambda is an option.

What is the complexity of the code? All executions must complete within 300 seconds. Long-running jobs are not appropriate for Lambda.

Lambda allocates CPU resources in proportion to the memory allocated to a Lambda function. For example, if a developer allocates 512 MB of memory to his function, he will get twice the CPU resources than if he had allocated only 256 MB of memory. If an individual's needs for CPU and memory are skewed to need significantly more CPU or memory, then Lambda may not be a good option for the application. A CPU-optimized or memory-optimized EC2 instance might be a better option.

If you are deploying instances for applications that are constantly polling for events elsewhere in your AWS infrastructure, then consider Lambda. With Lambda you only pay for the time your code runs. If a developer designs code to constantly check for infrequently occurring events, then instances will need to run continually. In this case, users will be charged for the full runtime even though the main application code only executed a fraction of that time.

Next Steps

VPC Python support bolsters Lambda service features

AWS Lambda useful in customizing Amazon Echo commands

Reduce IT overhead with AWS Lambda

This was last published in October 2015

Dig Deeper on AWS instances strategy and setup

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Join the conversation

1 comment

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

What is your level of integration with AWS Lambda?
Cancel

-ADS BY GOOGLE

SearchCloudApplications

TheServerSide.com

SearchSoftwareQuality

SearchCloudComputing

Close