With the rise of serverless technologies, services such as AWS Lambda have become increasingly popular. This article gives you an introduction to the features and benefits of using AWS Lambdas.

Lambda functions are executable functions that are hosted on AWS that only run whenever you invoke or call the Lambda. They can be written in a range of languages including C#, JavaScipt (through Node.js), Python 2 and 3, Go and Java. This means you can do really cool things like having a JavaScript stack but with a Python Lambda for machine learning or Go for running compute expensive tasks.

One of the major advantages of Lambdas is that you are only charged for the time it takes for the function to run. This means that functions that are called once every 10 minutes and take 2 seconds to run are charged for just 288 seconds per day (144 times a day x 2 seconds). That equates to 0.17 cents a month or $0.02 a year!

Another advantage of working with Lambdas is that they automatically scale at no extra cost. This could be scaling over time as your product grows as well as scaling up and down with the usage cycles throughout the day. If you have a Lambda that gets hit a lot throughout the day but less overnight then the Lambda will automatically provision the resources you need. This means that you aren’t wasting money on resources that are just sitting idle overnight, but won’t get server crashes if there is a user spike.

Cyclic nature of user activity

The third advantage to using AWS Lambda functions is their integration with other AWS services. Because they are run on AWS servers and are specific to your AWS account, you can access all of the other AWS services without needing to expose your credentials. This, combined with the fact that the aws-sdk is automatically installed on all Lambdas, makes pulling data from S3, working with Lex or running Elastic Beanstalk really easy.

As well as being able to call other functions from a Lambda, other services often provide Lambda as a method to handle an event trigger. This gives you the ability to make very powerful event tools. One example would be triggering a Lambda when an image gets uploaded to S3. This Lambda could then get that image, scale it to the required size, compress it and upload the meta data into an DynamoDB table. When all of that processing is done, it could send an email or text message to the user to tell them that their image has been processed and stored.

With the number of different services that can trigger and be triggered by Lambdas, the combinations that you can make are almost infinite.

Building your own Lambdas

Now that you know the advantages of using AWS Lambdas you probably want to know how you can harness these for yourself. The best way to start is in the Lambda console on AWS. Here you can create new Lambdas, edit, test and use them. This is great for smaller Lambdas where the functionality is relatively simple.

If you want to use a terminal to install packages to your Lambda, you could step up and use Cloud9 which is a hosted IDE on AWS. This integrated very well with Lambdas, allowing simple pulling and deploying.

The last option is to write the Lambdas on your local machine and upload them to AWS using Serverless. This is the cleanest and most scalable way to build Lambdas. If you want to learn how you can set up your own API using AWS and serverless then check out this FREE course.

Thanks for reading this article on AWS Lambdas. If you liked it make sure to hit that clap 👏button and follow me for more articles on the AWS Services!