The course is part of these learning paths
What is Compute?
Understanding the fundamentals of AWS is critical if you want to deploy services and resources within the AWS Cloud. The Compute category of services are key resources that allow you to carry out computational abilities via a series of instructions used by applications and systems. These resources cover a range of different services and features, these being:
- Amazon Elastic Compute Cloud (EC2)
- Elastic Load Balancing
- Auto Scaling
- Amazon EC2 Container Service (ECS)
- AWS Elastic Beanstalk
- AWS Lambda
- AWS Batch
- Amazon Lightsail
This course will provide the fundamental elements of all of these Compute services and features that will allow you to select the most appropriate service for your project and implementations. Each have their advantages by providing something of value that’s different to the others, which will all be discussed.
Topics covered within this course consist of:
- What is Compute: This lecture explains what 'Compute' is and what is meant by Compute resources and services
- Amazon Elastic Compute Cloud (EC2): This lecture discusses and explains what the EC2 service is and does, and provides a demonstration on how to configure, launch and connect to an EC2 instance
- Elastic Load Balancing & Auto Scaling: This lecture explains the differences between Elastic Load Balancing and Auto Scaling and how they can be used to help manage your fleet of EC2 Compute resources
- Amazon ECS: This lecture explains how the Amazon ECS service allows you to run Docker-enabled applications packaged as containers across a cluster of EC2 instances without requiring you to manage a complex and administratively heavy cluster management system
- AWS Elastic Beanstalk: This lecture provides an overview of the AWS Elastic Beanstalk service which helps to install, distribute and deploy web applications
- AWS Lambda: This lecture explains how AWS Lambda lets your run your own code in response to events in a scalable and highly available serverless environment
- AWS Batch: This lecture looks at AWS Batch and how this service is used to manage and run batch computing workloads within AWS
- Amazon Lightsail: This lecture looks at the Amazon Lightsail service which is essentially a Virtual Private Server (VPS) backed by AWS infrastructure
If you want to learn the differences between the different Compute services, then this course is for you!
With demonstrations provided, along with links to a number of our Labs that allow you to gain hands on experience in using many of these services will give you a solid understanding of the Compute services used within AWS.
If you have thoughts or suggestions for this course, please contact Cloud Academy at firstname.lastname@example.org.
Hello and welcome to this lecture where we shall take an introductory look at AWS Lambda.
The first point to make about AWS Lambda is that it's a service that lets you run your own code in response to events in a scalable and highly available serverless environment but what does serverless mean?
Essentially serverless means that you do not need to worry about provisioning and managing your own compute resource to run your own code. Instead, this is managed and provisioned by AWS. AWS will start, scale, maintain, and stop the compute resources required for as long as you need them, which can be as short as a few milliseconds depending on your Lambda function.
I'll cover more Lambda functions as we go through this lecture.
Although it's named serverless, it does of course require servers or at least computer power to carry out your code requests but because the AWS user does not need to be concerned with what compute power is used or where it comes from, it's considered serverless from the user perspective.
More information on serverless computing can be found within our existing course 'What is Serverless Computing' within the 'Getting Started with Serverless Computing' learning path.
Now we have a high level overview of what AWS Lambda is. Let's look at what it can be used for. AWS Lambda is great for a number of different use cases when you need to run and execute code in response to event-driven triggers. This makes it easy to build applications that will respond quickly to new information in addition to automating processes in existing applications and services.
For example, you could create a Lambda function to execute every time an image is uploaded to a particular bucket in S3, which will then compress the image into a zip format. This function will be triggered upon a PUT request to the bucket.
If you are proficient in writing in any of the supported languages of Lambda, which at the time of writing this course are Node.js, Java, C#, and Python, then you can create advanced event-driven processes within your environment. If you'd like additional examples and use cases of AWS Lambda, please take a look at the link on the screen.
One big difference between the compute power used for Lambda and that of EC2 for example is that with EC2, you are charged for that compute power by the hour, however, with AWS Lambda, you are only charged for the compute time used to the closest 100 milliseconds plus the number of request triggered by your function making this a very cheap compute option for running event-driven code.
Now let's take a look at how we can configure this service and understand some of the components, which will allow us to get a better understanding of how it works. For example, how AWS Lambda knows what compute resource it should use.
Let's start by defining what a Lambda function is. A Lambda function contains your code that you have written to perform the required task plus any dependencies for that code. In addition to this, the function also includes a number of configurational details, which are defined when a Lambda function is created.
- The required resources. The required resources provides just that, the resources that are required to carry out the execution of the code, however, the only input we have is to specify the amount of RAM required. The compute power is then determined by AWS Lambda using a ratio related to the amount of RAM specified.
- Maximum execution timeout, this specifies the maximum amount of time the Lambda function will run before it's terminated.
- IAM role, this grants the Lambda the appropriate permissions to carry out the execution of the code.
- Handler name, this refers to the method in your code where the execution of the function starts. When the function is triggered, any event information is passed as a parameter to the handler method.
- There is another key element of AWS Lambda, and that is defining the trigger that invokes the AWS Lambda function itself.
When creating a new Lambda function via the AWS Management Console, you are asked to define the trigger prior to either uploading or creating your code for the function. These triggers or event resources can be via another AWS service such as S3, DynamoDB, CloudFront, or by invoking the function on demand.
For a full list of event-driven resources, please see the following link.
At a high level, the configuration steps for creating an AWS Lambda function via the AWS Management Console is as follows. Firstly, select a blueprint. AWS Lambda provides a large number of common blueprint templates, which are preconfigured Lambda functions. To save time on your own code, you can select one of these blueprints, and then customize it as necessary. An example of one of these blueprints is S3-get-object, an Amazon S3 trigger that retrieves metadata for the object that is being updated.
Next, configure triggers. As I just explained, you are asked to define the trigger for the Lambda function. Using an example from step one, you would be required to answer a number of configurational questions relating to S3 such as specifying which S3 bucket the function will run on.
Configure the function, this section requires you to either upload your code or edit in line. This section also requires you to define the required resource, maximum execution timeout, the IAM role, and the handler name.
Once all this information has been entered, your AWS Lambda function has been created. The key benefit of using AWS Lambda is that it is a highly scalable serverless service coupled with fantastic cost optimization compared to EC2 as you are only charged for compute power whilst the code is running and for the number of functions called.
For your own hands-on experience with AWS Lambda, take a look at our labs, which will guide you through how to create your first Lambda function: Introduction to AWS Lambda, Automating EBS Snapshots with AWS Lambda, and Process Amazon S3 Events with AWS Lambda.
That now brings us to the end of this lecture covering AWS Lambda. Coming up in the next lecture, I shall discuss AWS batch.
About the Author
Stuart has been working within the IT industry for two decades covering a huge range of topic areas and technologies, from data centre and network infrastructure design, to cloud architecture and implementation.
To date Stuart has created over 40 courses relating to Cloud, most within the AWS category with a heavy focus on security and compliance
He is AWS certified and accredited in addition to being a published author covering topics across the AWS landscape.
In January 2016 Stuart was awarded ‘Expert of the Year Award 2015’ from Experts Exchange for his knowledge share within cloud services to the community.
Stuart enjoys writing about cloud technologies and you will find many of his articles within our blog pages.