04 - Compute Flashcards
Elastic Beanstalk
1) Platform as a Service (PaaS)
2) Deploy and manage your applications without worry about the underlying infrastructure
3) Does capacity provisioning, scaling
4) Supports Go, Java, .Net, Node.js, PHP, Python, Ruby, Web Containers / Docker Containers
5) Components: Application, Application Version, Environment
6) Deployment Policies: All at once, Rolling, Rolling with additional batch
Lambda
1) A serverless compute offering from AWS
2) Executes code only when needed
3) Automatic scaling
4) Provision the amount of memory you want to allocate to your functions and Lambda allocates the proportioned CPU power, bandwidth and disk I/O
5) Concurrent executions = (invocations per second) x (average execution durations in seconds
6) Supports Node.js, Java, C#, Go, Python, Ruby and custom runtimes
7) Supports synchronous and asynchronous invocation
8) Main integrations: API Gateway, Kinesis, DynamoDB, S3, IoT, SNS, SQS, Cognito, logging, and CloudWatch events
9) Ability to deploy within a VPC and assign security groups
10) Can use environment variables for different stages
11) Security: IAM execution role must be attached to Lambda
Lambda Part 2
1) Function (Program or script that Lambda runs)
* Function package has all necessary components for your function Code, files, etc.
* Function handler starts the actual code execution
2) Runtimes
* Different languages can be used and still run in the same execution environment
* Sits between Lambda and your code; relaying events, and responses between the two
3) Layers
* ZIP archive that contains libraries, custom runtimes or other dependencies
* Allows you to manage your dependencies separate from the unchanging code and resources
4) Event Source
* Non-streaming event sources (Push model) - Amazon Echo, S3, SNS, and Cognito
* Streaming-event sources (Pull model) - Amazon Kinesis, DynamoDB streams
5) Versions
* Great for testing; each version has its own ARN; traffic shifting
* When working on Lambda function, we are working on $LATEST
* Version = code + configuration
* Each version of the Lambda function can be accessed
6) Aliases
* “Pointers” to Lambda function version
* Enable Blue/Green deployment by assigning weights to Lambda functions
* Also have their own ARNs
7) Function Dependencies
* You must install the packages alongside your code and zip it together
* Upload the Zip file straight to Lambda if it is less than 50MB, otherwise upload to S3
Lambda Part 3
1) Concurrency - Up to 1000 executions
2) Can set reserved currencies at the function level
3) Each invocation over the concurrency limit will trigger a Throttle
4) Throttle behaviour:
* If sync invocation; return ThrottleError -429
* If async invocation; retry automatically (twice) and then go to DLQ
* DLQ can be a SNS topic or SQS queue
* Original event payload is sent to DLQ; great for debugging function issues
Lambda@Edge
1) Lambda that will run function for content that is being delivered by CloudFront
2) Functions are executed closer to the viewer
3) Functions will run in response to CloudFront events
4) Managed service
5) Deployed alongside the CloudFront CDN
Amazon Elastic Container Service (Amazon ECS)
1) Scalable Cluster service for hosting containers that
* Can scale up to thousands of Docker containers in seconds
* Monitors container deployment
* Manages the state of the cluster that runs the containers
* Schedules containers by using a build-in scheduler or third-party schduler (Apache Mesos, Blox)
* Can be launched with either AWS Fargate or Amazon EC2 launch types
2) Major Components: Task Definition, Service
Amazon ECS Deployments
1) Deployment Strategies
* maximumPercent parameter - Defines the maximum percentage of tasks that is allowed to be running or pending
* minimumPercent parameter - Defines the minimum percentage of tasks that is allowed to be running or pending
2) Load Balancing
* Classic - All tasks must be on the same instance
* ALB - Route all application layer; dynamic host port mapping; path based routing
* Network Load Balancer - Layer 4; High performance
Amazon Elastic Container Registry (ECR)
1) Managed AWS Docker registry service
2) Can use Docker CLI commands or Docker tools to maintain your workflow
3) ECR stores container images in S3
4) Can transfer container images to and from ECR via HTTPS
Amazon EC2 Cheat Sheet
1) Elastic Compute Cloud (EC2) is a Cloud Computing Service
2) Configure your EC2 by choosing your OS, Storage, Memory, Network Throughput
3) Launch and SSH into your server within minutes
4) EC2 comes in variety Instance Types specialised for different roles:
* General Purpose: balance of compute, memory and networking resources
* Compute Optimised: Ideal for compute bound applications that benefit from high performance processor
* Memory Optimised: Fast performance for workloads that process large data sets in memory
* Accelerated Optimised: Hardware accelerators, co-processors
* Storage Optimised: High, sequential read and write access to very large data sets on local storage
5) Instance Sizes generally double in price and key attributes
6) Placement Groups let you to choose the logical placement of your instances to optimise for communication, performance or durability. Placement groups are free
7) UserData - a script that will be automatically run when launching an EC2 instance
8) MetaData - meta data about the current instance. You can access this meta data via a local endpoint when SSH’d into the EC2 instance.
9) Instance Profiles - a container for an IAM role that you can use to pass role information to an EC2 instance when the instance starts
Amazon EC2 Pricing Cheat Sheet
1) EC2 has 4 pricing models: On-Demand, Spot, Reserved Instances (RI) and Dedicated
2) On-Demand (least commitment): low cost and flexible, only pay per hour, Ideal when your workloads cannot be interrupted
3) Reserved Instances up to 75% off (Best long-term value)
* Can resell unused reserved instances (Reserved Instance Marketplace)
* Reduced pricing is based on Term x Class Offering x Payment Option
* Payment Terms - 1 year or 3 years
* Payment Options: All Upfront, Partial Upfront, and No Upfront
* Class Offerings: Standard (Up to 75% reduced pricing compared to on-demand. Cannot change RI Attributes), Convertible (Up to 54% reduced pricing compared to on-demand. Allows you to change RI Attributes if greater or equal in value, Scheduled (You reserve instances for specific time periods eg. once a week for a few hours. Savings vary
4) Spot Pricing up to 90% off (Biggest Savings)
* Request spare computing capacity
* Flexible start and end times
* Can handle interruptions, for non-critical background jobs
* Instances can be terminated by AWS at anytime
* If your instance is terminated by AWS, you don’t get charged for a partial hour of usage
* If you terminate an instance you will still be charged for any hour that it ran
5) Dedicated Hosting (Most Expensive)
* Dedicated servers
* Can be on-demand or reserved (up to 70% off)
* Use case: When you need a guarantee of isolate hardware (enterprise requirements)
Amazon Machine Image (AMI) Cheat Sheet
1) AMI provides the information required to launch an instance
2) AMIs are region specific, if you need to use an AMI in another region you can copy an AMI into the destination region via Copy AMI
3) Community AMI are free AMIs maintained by the community
4) AWS Marketplace free or paid subscription AMIs maintained by vendors
5) AMIs have an AMI ID. The same AMI eg. (Amazon Linux 2) will vary in both AMI ID and options eg. Architecture options in different regions
6) An AMI holds the following information:
* A template for the root volume for the instance (EBS Snapshot or Instance Store template) eg. an operating system, an application server, and applications
* Launch permissions that control which AWS accounts can use the AMI to lunch instances
* A block device mapping that specifies the volumes to attach to the instance when it’s launched
Elastic Load Balancing (ELB) Cheat Sheet
1) There are 3 ELB: Network, Application, and Classic Load Balancer
2) A ELB must have at least 2 Availability Zones.
3) ELC cannot go cross-region. You must create one per region
4) ALB has Listeners, Rules, and Target Groups to route traffic
5) NLB use Listeners and Target Groups to route traffic
6) CLB use Listeners and EC2 instances are directly registered as targets to CLB
7) Use X-Forwarded-For (XFF) to get original IP of incoming traffic passing through ELB
8) You can attach Web Application Firewall (WAF) to ALB but not to NLB or CLB
9) You can attach Amazon Certification Manager SSL to any of the ELB for SSL
10) ALB has advanced Request Routing rules where you can route based on subdomain header, path and other HTTP(s) information
11) Sticky Sessions can be enable for CLB or ALB and session are remembered via Cookie
AWS Lambda Cheat Sheet
1) Lambda’s are serverless functions. You upload your code and it runs without you managing or provisioning any servers
2) Lambda is serverless. You don’t need to worry about underlying architecture
3) Lambda is a good fit for short running tasks where you don’t need to customise the OS environment. If you need long running tasks (>15 mins) and a custom OS environment than consider using Fargate
4) There are 7 runtime language environments officially supported by Lambda; Ruby, Python, Java, NodeJs, C#, Powershell and Go
5) You pay per invocation (The duration and the amount of memory used) rounded up to the nearest 100 milliseconds and you based on amount of requests. First 1M requests per month are free
6) You can adjust the duration timeout for up to 15 mins and memory up to 3008 MB
7) You can trigger Lambdas from the SDK or multiple AWS services eg. S3, API Gateway, DynamoDB
8) Lambdas by default run in No VPC. To interact with some services you need to have your Lambda in the same VPC eg. RDS
9) Lambda can scale to 1000 of concurrent functions in seconds. (1000 is the default, you can increase with AWS Service Limit Increase)
10) Lambdas have Cold Starts. If a function has not been recently been executed there will be a delay
11)
AWS Elastic Beanstalk Cheat Sheet
1) Elastic Beanstalk handles the deployment, from capacity provisioning, load balancing, auto-scaling to application health monitoring
2) When you want to run a web-application but you don’t want to have think about the underlying infrastructure
3) It costs nothing to use Elastic Beanstalk (only the resource it provisions eg. RDS, ELB, EC2)
4) Recommended for test or development apps. Not recommended for production use
5) You can choose from the following preconfigured platforms; Java, .NET, PHP, Node.js, Python, Ruby, Go, and Docker
6) You can run dockerized environments on Elastic Beanstalk