Serverless Flashcards
What does serverless mean?
Focus on the code and leave the management of compute architecture behind. AWS takes care of the physical data centers, the virtualization of computers. We are are responsible for the rest.
What are the benefits of serverless?
- Ease of use (we bring the code and AWS handles the rest)
- Event-based (serverless compute resources can be brought online in response to an event happening)
- Billing model (“pay as you go” in its purest form, you only pay for your provisioned resources and the length of runtime)
What are the two serverless compute options in AWS?
- Lambda - write a function and run it
- Fargate - run your code in a container
When given a scenario where one of the options is EC2 and the other is serverless, which would you recommend?
Serverless
What is Lambda?
AWS Lambda is a serverless compute service that lets you run your code without provisioning or managing the underlying servers
What are the five main settings are required when creating a Lambda function?
- Runtime - pick or bring your own
- Permissions - attach roles (e.g. to allow function to call AWS API)
- Networking - you can optionally define a VPC, subnet and security groups your function will be a part of
- Resources - defining the amount of available memory will allocate how much CPU and RAM your code gets
- Trigger - what is going to alert your Lambda function to start
If you have a scenario where you need to automatically remove entries from a security group, start and stop instances, or do anything else that is built-in, what service would you use?
Lambda
What are the limitations of Lambda?
- Time - runs for a maximum of 15 minutes
- Memory - maximum size of 10GB
What are common services that can trigger a Lambda function?
- S3
- CloudWatch Events
- EventBridge
- API Gateway
- ALB (Application Load Balancers)
When given a scenario where it asks what service would be best for writing microservices, what would you recommend?
Lambda
If you are given a scenario where you have a Lambda that needs access to private architecture (private database or private API), what would you recommend?
Run your Lambda in a VPC
What is the AWS Serverless Application Repository?
- Allows users to easily find, deploy or even publish their own serverless applications
- Ability to privately share applications within orgs or publicly for the world
- Upload the application code and a manifest file (known as the AWS SAM template)
- Deeply integrated with the AWS Lambda service (appears within the console)
What are the two options you have in the AWS Serverless Application Repository?
- Publish - publishing apps make them available for others to find and deploy (define apps with the SAM templates, set to private by default, must explicitly share if desired)
- Deploy - find and deploy published applications, browse public apps without needing an AWS account, browse within the AWS Lambda console
What is a container?
A container is a standard unit of software that packages up code and all its dependencies, so the application runs quickly and reliably from one computing environment to another.
A running copy of an image.
In terms of containers, what is a Dockerfile?
Text document that contains all the commands and instructions that will be used to build an image.
In terms of containers, what is an image?
Immutable file that contains the code, libraries, dependencies and configuration files needed to run an application.
In terms of containers, what is a registry?
Stores Docker images for distribution. They can be both private and public.
In terms of scenarios, what are important things to remember about containers?
- They are generally considered to be more flexible
- They are easier to run on-site and move around to different environments
What is ECS?
Elastic Container Service
- Management of containers at scale - ECS can manage 1, 10, hundreds or thousands of containers; it will appropriately place the containers and keep them online
- ELB integration - containers are appropriately registered with the load balancers as they come online and go offline
- Role integration - containers can have individual roles attached to them, making security a breeze
- Ease of use - extremely easy to set up and scale to handle any workload
What is an open-source alternative to ECS?
Kubernetes
- Open-source alternative
- Can be used on-premises and in the cloud
- AWS managed version is called Elastic Kubernetes Service (EKS)
How do you decide between using ECS and EKS?
ECS - proprietary AWS container management solution (best used when you are all in for AWS and looking for something simple)
EKS - AWS managed version of open-source Kubernetes container managed solution (best used when you are not all-in on AWS, because it is more work to configure and integrate with AWS)
Generally assume that in scenarios, ECS is the best option, with the only exception being if open-source, Kubernetes or running the container on-premises, then assume EKS is best.
If you see a scenario that talks about Kubernetes, what service would you recommend?
EKS (Elastic Kubernetes Service)
If you have a scenario that requires a long-running application, what service would you recommend?
ECS (Elastic Container Service)
What is Fargate?
AWS Fargate is a serverless compute engine for containers that works with both ECS and EKS
- AWS owns the infrastructure
- Requires use of ECS or EKS
How do you decide between using ECS and Fargate in ECS and EKS?
EC2
- You’re responsible for the underlying operating system
- EC2 pricing model (EC2 is a better deal)
- EC2 excels for long-running containers
- Multiple containers can share the same host
Fargate
- No operating system access
- Pay based on resources allocated and time ran
- Fargate excels for short-running tasks
- Isolates environments
How do you decide between Lambda and Fargate?
Lambda
- Great for unpredictable or inconsistent workloads
- Perfect for applications that can be expressed as a function
Fargate
- Select Fargate when you have more consistent workloads
- Allows Docker use across the organization and a greater level of control by developers
What is EventBridge?
Amazon EventBridge (formally known as CloudWatch Events) is a serverless event bus. It allows you to pass events from a source to an endpoint. Essentially, it is the glue that holds your serverless application together.
How do you create a rule in EventBridge?
- Define a pattern (do you want the rule to be invoked based on what event is happening, or do you want this to be scheduled?)
- Select event bus (is this going to be an AWS-based event, a custom event or partner?)
- Select your target (what happens when this event gets kicked off, do you want to trigger a Lambda function, post to an SQS queue, send an email, etc.?)
- Tag
- Sit back and wait for the event to happen, or kick it off yourself to make sure it is working correctly