DEV Community

Fernando Pena
Fernando Pena

Posted on • Updated on • Originally published at blog.pena.rocks

 

AWS Lambda | How to run your code without a server

In this post I will tell you a bit more about how you can run your programs without the need to instantiate a server just for that. We are talking about a serverless architecture. For this I will introduce you to the AWS service called AWS Lambda.

I will also show you step by step, showing how simple it is to use the service, and also for free.


AWS Lambda Introduction

I will split this post into two main parts, Theoretical (this post) and Practical (a new post, link below).

However, I recommend that you don't skip the theoretical part, because this is exactly where I explain what AWS Lambda is all about. It's quick, so let's go.

Theoretical Part Contents:

  • What is the AWS Lambda service?
  • Free Usage Level
  • AWS Lambda vs EC2 (Serverless vs Server)

Contents of the Practical Part in a new link:

  • Step by step to create an AWS Lambda Function from scratch, with Amazon S3 triggers.

What is the AWS Lambda service?

"AWS Lambda is a serverless, event-driven compute service that lets you run code for virtually any type of application or backend service without provisioning or managing servers." (source: https://aws.amazon.com/pt/lambda/)

Image description

In other words, this service allows you to execute a certain code without worrying about machine instantiation, maintenance, server scaling, service installation, etc.

And in this case, another advantage is that you pay only for what you use, i.e. for each request and according to the size and time of execution.

When you have an instantiated server, you pay for the time that server is on air, even if you are not using it.


Free Usage Level

There is a free tier to use the AWS Lambda service, where you can run up to 1 million requests per month, or up to 400,000GB/second per month.

Which is very helpful if you want to do testing or even run low workloads.

More up-to-date information:

https://aws.amazon.com/pt/lambda/pricing/?loc=ft#Free_Tier


AWS Lambda vs EC2 (Elastic Compute Cloud), which is better?

This is not even a valid comparison, the answer here is "It depends". No one wants to hear "It depends" as an answer, but this is a case that needs analysis and varies a lot from scenario to scenario. So you have to analyze the architecture, the volumetry, usage, etc.

For example, if you use AWS Lambda to make some infrequent requests during the month, then it will certainly be "cheaper" than keeping an EC2 machine running 24/7, but that doesn't mean it is the best or the right thing. If on the other hand you have a service that has a high volume of access, with large workloads, it will probably be cheaper to have a good EC2 instance capable of supporting the workload, but again, it doesn't mean it's the best, it will depend a lot on the architecture.

And you need to take into consideration other variables like scalability, high availability and so on.

Image description

If you want to know more about EC2 instances, here is a video where I talk about exactly that:

[Step-by-Step] Amazon EC2 - How to Upgrade a Free Server on AWS


Step by Step - Creating an AWS Lambda Function from scratch, using Amazon S3 triggers.

To keep the content from getting too long in this post, the practical part is separated in the post below:

Step by Step - Creating an AWS Lambda Function from scratch using Amazon S3 triggers.


Subscribe to my Youtube channel:
Youtube: Pena Rocks

Follow me on social networks:
Instagram: https://www.instagram.com/pena.rocks/
Twitter: https://twitter.com/nandopena
LinkedIn: https://www.linkedin.com/in/nandopena/

More Information:
https://www.pena.rocks/

Top comments (0)