We have the answers to your questions! - Don't miss our next open house about the data universe!

AWS Lambda Explained: Unveiling the Power of Serverless Functions on Amazon Web Services

aws lambda

Introduced in 2014, AWS Lambda is a serverless Function as a Service platform. What does this mean? What are the main use cases? That's what we're going to detail in this article, to explain the growing popularity of the service.

What is AWS Lambda?

Basically, the principle behind AWS Lambda is very simple. It’s a matter of deploying functions (i.e., code) that react to events, without having to worry about the underlying infrastructure.

In other words, you don’t need to instantiate the virtual machines (servers) on which your application will run. AWS takes care of the execution environment for you. It’s for this reason that we speak of serverless service: although there are of course servers to host the application, they are totally abstracted from the customer.

This has three main advantages:

  • Reduce (and even eliminate) the time spent on server management: maintenance, updates, security patches, etc.
  • Enable near-infinite scalability by default: whether the function is run once a day or over a million times, AWS will adapt the service accordingly, without you needing to manage load balancing and auto-scaling.
  • Load balancing involves distributing tasks (e.g. requests to be processed) over a set of servers rather than a single one, in order to make the overall process more efficient.
    Auto scaling consists in automatically adjusting computing capacity (i.e. the number of servers behind the load balancer) according to load (which can be measured, for example, by the number of requests per minute).
  • Allow invoicing according to usage: invoicing is done per millisecond of execution. If the function is not executed, you simply won’t be billed.

As there is no server running all the time, function execution must be triggered by events.

The sources of events can be very diverse: you can trigger the execution of a function when a file is uploaded to an S3 bucket, when a record is added to a DynamoDB table, in response to an HTTP request (via integration with the API Gateway service), or simply via scheduling (you can decide to invoke the function periodically, every minute or hour for example).

Some use cases

The use cases for AWS Lambda functions are extremely varied, thanks to the large number of integrations with other services as source events. These include real-time data processing, file transformation and even backends for web and mobile applications.

Image preview generation

One of the most common use-case examples is the generation of thumbnails when an image is uploaded to an S3 bucket.

Suppose you’re developing an application that lets users upload and share images. You want users to be able to import very high-resolution photos, but you want to display low-resolution previews on the image gallery, so that it loads quickly.

To achieve this, you can use S3 and Lambda: a first S3 compartment can be used to store your users’ images. Using event notification, you can invoke a Lambda function each time a file is created in this compartment. This function can then generate a preview from the image, then store it in a new compartment, which will therefore contain all thumbails :

Thanks to this serverless, event-driven architecture, your application will scale automatically according to the number of uploads made by users.

We could easily imagine other similar applications:

  • Generation of an automatic transcription (via AWS Transcribe) when an audio file is uploaded.
  • Real-time processing of data from a stream (Kinesis, Kafka).

Web and mobile applications backends

Another very common application for AWS Lambda functions is backend development for mobile or web applications.

Indeed, you can use a Lambda function to process requests to API Gateway.

By also using a database such as DynamoDB, you can develop fully serverless backends (web, application and database layers), which will scale perfectly according to usage:

Further information

As you can see, AWS Lambda can be used for a wide variety of applications, which partly explains its growing popularity.

There are, however, certain limitations and complexities inherent in the use of Lambda functions.

One of these is the maximum execution time of a function, which is 15 minutes: Lambda functions are not designed to perform time-consuming tasks. For example, if you want to perform Machine Learning model training, AWS Lambda will probably not be the right choice. Function memory is also limited to 10GB, and CPU power to 6 vCPUs.

Another complexity is the difficulty of developing and deploying complex applications with Lambda.

Indeed, to create a fairly simple function, you can simply go through the AWS console:

Further information

As you can see, AWS Lambda can be used for a wide variety of applications, which partly explains its growing popularity.

There are, however, certain limitations and complexities inherent in the use of Lambda functions.

One of these is the maximum execution time of a function, which is 15 minutes: Lambda functions are not designed to perform time-consuming tasks. For example, if you want to perform Machine Learning model training, AWS Lambda will probably not be the right choice. Function memory is also limited to 10GB, and CPU power to 6 vCPUs.

Another complexity is the difficulty of developing and deploying complex applications with Lambda.

Indeed, to create a fairly simple function, you can simply go through the AWS console:

But as application code grows, using the development environment integrated into the AWS console proves inefficient, if not impossible.

In this case, you need to develop your application locally on your computer, and have a repeatable process for packaging your code and deploying it on AWS, which can prove complex.

To simplify this task (and more), you can use the Serverless framework, which lets you define your Lambda functions and associated code, their integrations and other serverless resources (e.g. DynamoDB tables). Once this stack has been defined, you can deploy it on AWS very simply using the framework.

Conclusion

If you’d like to find out more about AWS Lambda functions, and more generally about the architecture of IT systems in the AWS cloud, you can sign up for one of our training courses on this cloud provider.

You are not available?

Leave us your e-mail, so that we can send you your new articles when they are published!
icon newsletter

DataNews

Get monthly insider insights from experts directly in your mailbox