Airplane has been acquired by Airtable. Learn more →
gradient
What is AWS Lambda?

What is AWS Lambda?

Keanan Koppenhaver
Developer Advocate
Aug 1, 2023
6 min read

As one of the first platforms to popularize serverless computing, AWS Lambda provided an alternative infrastructure model to the traditional server-driven architecture that had been popular for years. Instead of deploying your entire application to an always-running server, your business logic, represented as functions, could be deployed to AWS Lambda where you didn’t have to worry about provisioning specific infrastructure and only paid for the time when your code was actually running.

While this model can be very helpful in certain situations, serverless isn’t for everyone. In this article, we’ll take a look at what AWS Lambda is, how it works and whether it might be a good fit for your next project.

Understanding serverless computing

Despite the name, serverless doesn’t mean that there are no servers involved. It just means that servers are utilized differently and that the end user isn’t responsible for the provision, maintenance or upkeep of the servers at work in their infrastructure. There are three core concepts that are key to a serverless architecture:

  • Functions: Functions are small, self-contained blocks of code that perform specific tasks or operations and are core to any serverless architecture. They can be written in most any language (especially given AWS Lambda layers) but it’s important that they are stateless and event-driven. Because each request is invoked separately, functions don’t have the benefit of sharing state from previous runs (unless a database or some other storage mechanism is involved). This means each serverless function you create should be stateless and able to be evoked in response to an event.
  • Events: Actions or changes within the system or external environment that cause functions to run are known as events. Events can be many different things such as HTTP requests, database modifications, messages from queues, or scheduled tasks. Ultimately, deciding which events are important to your system will dictate how you build your various serverless functions.
  • Triggers: Triggers act as bridges between events and functions. They listen for specific events and invoke the corresponding functions when an event occurs. Triggers are responsible for mapping events to the appropriate functions.

Introducing AWS Lambda

AWS Lambda combines all these concepts inside the AWS context, allowing developers to take the idea of serverless functions, events and triggers and tie them into the AWS infrastructure they are already using.

  • Functions: For creating functions, AWS Lambda offers a code editor right within the AWS Console. As your serverless functions get more complex, Lambda also supports deploying via a .zip file, either directly via the CLI or via upload to S3.
A look at the AWS Lambda code editor
  • Triggers: Possibly one of the strongest reasons to choose Lambda is the fact that you can use most any other AWS service as a trigger in your serverless architecture. You can configure your Lambda functions to watch an S3 bucket for changes, listen to an SQS queue, or be the backend to an API driven by API Gateway.
A view of some example triggers for AWS Lambda

Supported programming languages

By default, Lambda supports .NET, Go, Java, NodeJS, Python and Ruby runtimes. However with AWS Lambda Layers, developers can write Lambda functions in almost any language as well as leverage external libraries and other dependencies.

Pricing

In addition to being a great tool for linking AWS services together, Lambda also brought the AWS pricing model to its serverless offering. When AWS launched, the idea that you could pay for servers by the hour was not common, however that’s now how many cloud resources are priced. AWS Lambda is no exception to this rule, however, instead of pricing by the hour, AWS Lambda pricing is calculated by how long your function takes to execute (in milliseconds) and how much memory it uses. This means you only pay for the computing time and power that you actually use and allows teams, especially those with “bursty” workflows, to optimize costs.

AWS Lambda use cases

Lambda functions have many potential use cases, especially for teams and organizations who already utilize AWS.

Real-time data processing and analysis

If you have data flowing from sources such as IoT devices, logs, clickstream data, or any other event-based system that needs to be processed or analyzed, AWS Lambda might be just the tool that you need. Wherever your data originates can be set up as the trigger, meaning that your Lambda function would run whenever new data is present at the source. After your function handles any processing or analysis on the data passing through it, it can be sent to a destination, either longer-term storage or the next step in the data processing pipeline. And since you only pay for the computation time you use, if you get data in batches, you don’t have to pay to keep a server running for this processing when you’re not actively processing data.

For more information on how to process your data with AWS Lambda, check out this tutorial from AWS.

Image and video processing

Another common use for AWS Lambda is media processing. If you have a web site or web application that accepts user-uploaded media, you likely need a way to convert that media into various sizes for use across your site. For example, if a user uploads a profile picture, you might want to generate a thumbnail sized image so that you can display it efficiently in smaller orientations. With AWS Lambda, you can watch a particular S3 bucket for any new image uploads, run your function to resize the image and then put the new thumbnail size image back in the same bucket, accessible and ready to be used by your application.

If this is a use case that you’re interested in exploring for your application, AWS has an implementation guide with more information.

Chatbots and voice applications

Because Chatbots and voice applications (such as Amazon Alexa applications) are naturally event-driven, they can be a great fit for the serverless model. In this case, a chat message or a voice message would be the trigger, your Lambda function would parse the information and decide how to take action and the response based on that action would be sent back to the chatbot or voice application and the user on the other side.

And since Alexa skills are especially easy to build on AWS Lambda, AWS has produced extensive documentation on how to do just that.

Limitations of AWS Lambda

As powerful as Lambda is, there are some limitations you should be aware of when considering it for your next project.

  • Function size and execution time: By default, Lambda functions have a 15 minute limit on execution time and a 250MB limit on total function size. Especially for functions with lots of dependencies, this can become a problem. If you have a long-running function or one that can’t be broken down into any smaller functions, you may need to consider another solution.
  • Rate limits and concurrency: If you have a workflow that requires many invocations of your Lambda function at the same time, you may run into problems with AWS Lambda’s rate limits. These can be adjusted by contacting AWS Support, but if you are finding this to consistently be a problem, you might be better off avoiding a serverless infrastructure. In addition, since each function runs independently, some Lambda implementations experience a “cold start” delay. While this can be avoided using provisioned concurrency, this is an additional piece of your infrastructure you would need to configure.
  • Cost transparency: Despite Lambda using a “pay for what you use” model, it can sometimes be difficult to determine exactly what you’re going to pay based on your estimated usage. There are many factors that come into play with regards to AWS Lambda pricing and it’s important to consider whether using a traditional server-based infrastructure might be more cost effective for your use case.

AWS Lambda Alternatives

Given AWS Lambda’s popularity, it’s not surprising that other cloud providers have also deployed serverless solutions for their customers. If you are a Google Cloud customer, take a look at Google Cloud Functions. If you use Microsoft’s Azure, Azure Functions is available.

However, if you don’t already use one of these cloud providers and are looking for a straightforward, easy-to-use serverless platform to run your functions, consider Airplane.

Out of the box, Airplane supports NodeJS and Python functions (just like AWS Lambda), but also lets you execute your functions on a schedule, turn database queries and scripts into powerful internal tools and even supports creating custom React-based UIs on top of the tools you build. With the recent release of Airplane’s webhooks feature, you can now invoke your tasks any time you need them, from any of your other tools or applications.

If you'd like to test out Airplane and build your next serverless function in minutes, sign up for a free account today!

Is AWS Lambda the solution for you?

If you’re looking to optimize your infrastructure and not have to worry about provisioning and managing servers, a serverless offering like AWS Lambda could be right for your next project. If your use case fits well into the event-driven model at the core of Lambda and your implementation won’t be held back by any of the limitations of the platform, it can be a very powerful tool in your development toolbox.

Share this article:
Keanan Koppenhaver
Developer Advocate
Keanan is a Developer Advocate at Airplane. He's passionate about teaching other developers and helping them level up their skills.

Subscribe to new blog posts from Airplane.