In the new era of cloud computing, it’s become possible to create back-end infrastructures entirely with cloud-based components. The emphasis is on turn-key, effortless computing, moving databases and servers—two pillars of back-end functionality—off-site and into the cloud. It helps eliminate a lot of server management and maintenance, which is a major benefit for lean development teams who want to focus more on creating services and less on the maintenance that comes with them.

This is where Amazon Web Services (AWS) excels. If you need a scalable, reliable server to run your application’s code, it offers a slew of options, some more hands-off than others. If you’re willing to sacrifice a little flexibility for convenience, AWS’s Lambda is an excellent option.

A Look at Serverless Architectures with AWS

Serverless means what it sounds like: You’re removing server hardware and the provisioning of that hardware from the equation. AWS has a few options to create instances and host containers in the cloud. You might have heard of AWS’s Elastic Compute Cloud (EC2), which offers instant provisioning and autoscaling with and support for containers. With EC2, developers still handle the server setup and application provisioning, but AWS handles provisioning. Similarly, Amazon’s EC2 Container Service (ECS) lets you run your container in the cloud, handling application provisioning for you (and server setup, with Fargate).

But if you’re not overly particular about how or where your code is run—just as long as it’s reliable and fast—AWS Lambda offers an even more managed solution. Lambda essentially takes ECS to the next level. It was introduced in 2014 as an entirely new application paradigm: a serverless architecture that eliminates server setup and provisioning as well as container and application setup. All you need to do is provide the code and AWS handles the setup and provisioning for you, allocating the necessary resources you require.

Lambda Benefits and Basics

[Image via.]

Lambda is a serverless compute service that lets organizations run nearly any code under the sun without the time-consuming administration that comes with setting up and provisioning servers. For AWS clients, it’s a natural fit for extending other AWS services.

As more and more dynamic applications like chatbots require high availability of real-time data and lightning-fast computing to deliver high-quality user experience, there’s a demand for a reliable, low-fault-tolerance environment that can meet their fluctuating demands.

First, let’s look at some Lambda basics. (For a full rundown of its benefits and features, check out the AWS documentation here.)

  • Top-notch, reliable AWS performance. Run your logic layer on services that leverage AWS’s high availability, performance, scale, and built-in security. If and when your usage grows, it can scale with you automatically.
  • Forget server administration. Run code for almost any kind of application, site, or service without worrying about server provisioning and maintenance, including security patches, operating system upgrades, automatic scaling, monitoring, and logging. In Amazon’s words, “All you need to do is supply the code,” and it will supply the CPU, memory, network, and more.
  • You’ll pay only for the compute time your app consumes. When an event is triggered (a modification to a database table, an API call, an HTTPS request, etc.), Lambda will automatically run your code, and that’s all you’ll be charged for—not for any idle capacity. Billing is measured in increments of 100 milliseconds.
  • Scaling without limits. If your request rate increases—and there are no limits to the number of requests your app can accept with Lambda—it’s scaled automatically.
  • Meets most compliance requirements. AWS Lambda is SOC, HIPAA, PCI, and ISO compliant.

Get a full rundown of Lambda’s features here.

Lambda Functions

Understanding functions and how they are set up is critical to being able to accurately gauge if your project is a good fit for Lambda. If you’re a developer, learn more about how to create functions in this tutorial.

Functions are Lambda’s own unit of deployment and execution—they’re behind what makes it able to handle multiple, simultaneous requests to your app in parallel. It’s necessary to create functions that contain the code you want to run when that event is triggered. Once you’ve created and configured those functions, Lambda will automatically scale them for you every time that event is triggered.

There are certain considerations to be aware of if you’re running a feature-rich REST app. Upwork back-end engineer Ilya Obshadko notes, “Your application will be structured in terms of Lambda functions, which act as dispatchers for your REST endpoints. This creates additional challenges for properly organizing your code base, adequately sizing the functionality that every particular function supports, and avoiding code duplications across functions.”

Is AWS Lambda Right for Your Project?

Generally, the more complicated and feature-rich your application is, the more up-front work you’ll have to do to create Lambda functions. A Lambda setup is not without up-front work, but this is easier if your project already runs AWS-centered tasks. These can include:

  • Processing incoming email from SES (Simple Email Service)
  • Managing files in S3 (Simple Storage Service)
  • Managing Elasticsearch indexes in ES (Elasticsearch Service)
  • Processing CloudWatch events in a particular way

When it comes to non-AWS-centered projects, Obshadko encourages developers to consider the pros and cons. “The first time you try to use Lambda with something not managed by AWS, whether it’s a relational database, an external service, or even a third-party library, everything immediately becomes more complex, and you’ll sacrifice some efficiency.”

When you’re weighing the options for a computing solution for your site or app, there’s a lot to consider. How much availability does your app require? Is it a highly reactive, event-driven application with multiple requests occurring simultaneously (e.g., a chatbot)? How much do you anticipate it to grow? Answering these questions will help you determine what you’ll need in the way of scalability, provisioning, and capacity.

Some other considerations:

Your code has to be compatible with the Lambda run-time environment. While Lambda allows you to bring your own code, it does have to be supported by the run-time environment. Languages supported at this time include Python, Java, Node.js, Go, and C#. It’s possible to execute code written in another programming language (PHP, Go,
Smalltalk, Ruby, etc.), as long as it’s staged and invoked from within
one of the supported languages.

You don’t need the flexibility to customize OS or language run-time. There’s always a trade-off when it comes to efficiency and flexibility. Because AWS is managing and balancing your instances for you, you’re not able to log in and edit your compute resources yourself. For that capability, there are other AWS compute services you can use such as Amazon EC2.

Lambda is particularly well suited for:

  • Microservices
  • IoT applications
    Real-time data processing (e.g. automatically resizing an image to optimize it for viewing on different devices)
    Real-time stream processing (e.g. importing a social stream to an analytics platform)
    Virtual assistant software
    Chatbots
    Web app and mobile app back ends

Check out some more use cases for Lambda here.