AWS Solution Architect(Associate) - Topic 10: Serverless Architecture
A serverless architecture is a way to build and run applications and services without having to manage infrastructure. Your application still runs on servers, but all the server management is done by AWS.
You no longer have to provision, scale, and maintain servers to run your applications, databases, and storage systems. Learn more about serverless computing here.
Serverless
Lambda
AWS Lambda is a serverless compute service that lets you run code without provisioning or managing servers, creating workload-aware cluster scaling logic, maintaining event integrations, or managing runtimes.
- Lambda scales out (not up) automatically
- Lambda functions are independent, 1 event = 1 function
- Lambda is serverless
- Know what services are serverless
- RDS is not serverless (Aurora service is a exception) even though AWS takes care of its operation system, there is still an operating system that they have to go in and you still gonna have downtime when they’re doing maintenance.
- DynamoDB is serverless
- S3 is serverless
- API Gateway is serverless
- EC2 is not serverless, because it’s obviously a virtual machine
- Lambda functions can trigger other lambda functions, 1 event can = x functions if functions trigger other functions
- Architectures can get extremely complicated, AWS X-ray allows you to debug what is happening
- Lambda can do things globally, you can use it to back up S3 buckets to other S3 buckets etc.
Serverless Application Model (SAM)
The AWS Serverless Application Model (SAM) is an open-source framework for building serverless applications. It provides shorthand syntax to express functions, APIs, databases, and event source mappings.
- CloudFormation extension optimized for serverless applications
- New types: functions, APIs, tables
- Supports anything CloudFormation supports
- Run serverless applications locally
- Package and deploy using CodeDeploy
Elastic Container Service (ECS)
Amazon Elastic Container Service (Amazon ECS) is a fully managed container orchestration service. Customers such as Duolingo, Samsung, GE, and Cookpad use ECS to run their most sensitive and mission critical applications because of its security, reliability, and scalability.
What are Containers and Docker?
- A container is a package that contains an application, libraries, runtime, and tools required to run it
- Run on a container engine like Docker
- Provides the isolation benefits of virtualization with less overhead and faster starts than VMs
- Containerized applications are portable and offer a consistent environment
What is ECS?
- Managed container orchestration service
- Create cluster to manage fleets of container deployments
- ECS manages EC2 or Fargate instances
- Schedules containers for optimal placement
- Defines rules for CPU and memory requirements
- Monitor resource utilization
- Deploy, update, roll back
- FREE
- VPC, security groups, EBS volumes
- ELB
- CloudTrail and CloudWatch (Native support for CloudWatch so that you can get alarmed on state changes in the cluster)
ECS Components
- Cluster: Logical collection of ECS resources — either ECS EC2 instance or Fargate instances
- Task: Single running copy of any containers defined by a task definition.
- Task Definition: Defines your application
- Service: Allows task definitions to be scaled by adding tasks
- Container Definition: Inside a task definition, it defines the individual containers a task uses
- Registry: Storage for container images
Fargate
- Serverless container engine
- Eliminates need to provision and manage servers
- Specify and pay fore resources per application
- Works with both ECS and EKS
- Each workload runs in its own kernel
- Isolation and security
- Choose EC2 instead if:
- Compliance requirements
- Require broader customization
- Require GPUs
Elastic Kubernetes Service (EKS)
- K8s is open-source software that lets you deploy and manage containerized applications at scale
- Same toolset on-premises and in cloud
- Containers are grouped in pods
- Like ECS, supports both EC2 and Fargate
- Why use EKS?
- Already using K8s
- Want to migrate to AWS
Elastic Container Registry (ECR)
- Managed Docker container registry
- Store, manage, and deploy images
- Integrated with ECS and EKS
- Works with on-premises deployments
- Highly available
- Integrated with IAM
- Pay for storage and data transfer
ECS (Elastic Container Service) + ELB (Elastic Load Balancing)
- Distribute traffic evenly across tasks in your service
- Supports ALB (Application Load Balancer), NLB (Network Load Balancer), CLB (Classic Load Balancer)
- Use ALB to route HTTP/HTTPS (layer 7) traffic
- Use NLB or CLB to route TCP (layer 4) traffic
- Supported by both EC2 and Fargate launch types
- ALB allows:
- Dynamic host port mapping
- Path-based routing
- Priority rules
- ALB is recommended over NLB or CLB
References
Containers
AWS Developer Blog
- AWS Compute Blog
Dive Into Exam
- What AWS service can be used to help resolve an issue with a lambda function?
- Answer: AWS X-Ray
- Explanation: AWS X-Ray helps developers analyze and debug production, distributed applications, such as those built using a microservices & serverless architectures.
AWS Solution Architect(Associate) - Topic 10: Serverless Architecture
http://vincentgaohj.github.io/Blog/2021/04/16/AWS-Solution-Architect-Associate-10-Serverless/