Add a couple of AWS questions and exercises

EBS & ELB mainly.
This commit is contained in:
abregman 2021-11-20 22:59:23 +02:00
parent c93d394d9b
commit 899c510e76
9 changed files with 316 additions and 31 deletions

View File

@ -10,7 +10,7 @@
:busts_in_silhouette:  Join our [DevOps community](https://www.facebook.com/groups/538897960007080) where we have discussions and share resources on DevOps
:pencil:  You can add more questions and exercises by submitting pull requests :) Read about contribution guidelines [here](CONTRIBUTING.md)
:pencil:  You can add more exercises by submitting pull requests :) Read about contribution guidelines [here](CONTRIBUTING.md)
****
@ -7605,7 +7605,7 @@ A load balancer accepts (or denies) incoming network traffic from a client, and
</b></details>
<details>
<summary>What benefits load balancers provide?</summary><br><b>
<summary>Why to used a load balancer?</summary><br><b>
* Scalability - using a load balancer, you can possibly add more servers in the backend to handle more requests/traffic from the clients, as opposed to using one server.
* Redundancy - if one server in the backend dies, the load balancer will keep forwarding the traffic/requests to the second server so users won't even notice one of the servers in the backend is down.
@ -8276,6 +8276,12 @@ With vertical scaling alone, the component still remains a single point of failu
In addition, it has hardware limit where if you don't have more resources, you might not be able to scale vertically.
</b></details>
<details>
<summary>Which type of cloud services usually support vertical scaling?</summary><br><b>
Databases, cache. It's common mostly for non-distributed systems.
</b></details>
<details>
<summary>Explain Horizontal Scaling</summary><br><b>
@ -8283,7 +8289,7 @@ Horizontal Scaling is the process of adding more resources that will be able han
</b></details>
<details>
<summary>What is the disadvange of Horizontal Scaling? What is often required in order to perform Horizontal Scaling?</summary><br><b>
<summary>What is the disadvantage of Horizontal Scaling? What is often required in order to perform Horizontal Scaling?</summary><br><b>
A load balancer. You can add more resources, but if you would like them to be part of the process, you have to serve them the requests/responses.
Also, data inconsistency is a concern with horizontal scaling.

View File

@ -29,6 +29,14 @@ Note: Provided solutions are using the AWS console. It's recommended you'll use
| Volume Creation | EC2, EBS | [Exercise](ebs_volume_creation.md) | [Solution](solutions/ebs_volume_creation.md) | Easy |
| Snapshots | EC2, EBS | [Exercise](snapshots.md) | [Solution](solutions/snapshots.md) | Easy |
| Create an AMI | EC2, AMI | [Exercise](create_ami.md) | [Solution](solutions/create_ami.md) | Easy |
| Create EFS | EC2, EFS | [Exercise](create_efs.md) | [Solution](solutions/create_efs.md) | Easy |
#### AWS - ELB
|Name|Topic|Objective & Instructions|Solution|Comments|
|--------|--------|------|----|----|
| Application Load Balancer | ELB, ALB | [Exercise](app_load_balancer.md) | [Solution](solutions/app_load_balancer.md) | Easy |
| Multiple Target Groups | ELB, ALB | [Exercise](alb_multiple_target_groups.md) | [Solution](solutions/alb_multiple_target_groups.md) | Easy |
#### AWS - Lambda
@ -341,10 +349,10 @@ Storage Optimized:
EBS
</b></details>
##### AWS EC2 - Storage
##### AWS EC2 - EBS
<details>
<summary>Explain what is Amazon EBS</summary><br><b>
<summary>Explain Amazon EBS</summary><br><b>
[AWS Docs](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AmazonEBS.html): "provides block level storage volumes for use with EC2 instances. EBS volumes behave like raw, unformatted block devices."
</b></details>
@ -393,12 +401,6 @@ Yes, with multi-attach it's possible to attach a single EBS volume to multiple i
True
</b></details>
<details>
<summary>How to move EBS volumes between availability zones?</summary><br><b>
Using snapshots.
</b></details>
<details>
<summary>What EBS volume types are there?</summary><br><b>
@ -438,6 +440,14 @@ HDD - sc1
SSD: gp2, gp3, io1, io2
</b></details>
<details>
<summary>True or False? In EBS gp2 volume type, IP will increase if the disk size increases</summary><br><b>
True.
</b></details>
##### AWS EC2 - Instance Store
<details>
<summary>If you would like to have an hardware disk attached to your EC2 instead of a network one (EBS). What would you use?</summary><br><b>
@ -494,15 +504,33 @@ False. EFS scales automatically and you pay-per-use.
</b></details>
<details>
<summary>Which EFS mode would you use if need maximum throughput?</summary><br><b>
<summary>What EFS modes are there?</summary><br><b>
Performance Mode (Max I/O): This provides high throughput and it's used for big data, media processing, etc.
* Performance mode
* General purpose: used mainly for CMS, web serving, ... as it's optimal for latency sensitive applications
* Max I/O: great for scaling to high levels of throughput and I/O operations per second
* Throughput mode
* Bursting: scale throughput based on FS size
* Provisioned: fixed throughput
</b></details>
<details>
<summary>Which EFS mode would you use if you need to perform media processing?</summary><br><b>
Performance Mode (Max I/O): It provides high throughput and scales to operations per second. Mainly used for big data, media processing, etc.
</b></details>
<details>
<summary>What is the default EFS mode?</summary><br><b>
Performance Mode (General Purpose): Used for web servers, CMS, etc.
Performance Mode (General Purpose): Used for web serving, CMS, ... anything that is sensitive to latency.
</b></details>
<details>
<summary>What EFS storage tiers are there?</summary><br><b>
* Standard: frequently accessed files
* Infrequent access: lower prices to store files but it also costs to retrieve them
</b></details>
##### AWS EC2 - Pricing Models
@ -825,7 +853,7 @@ Amazon definition: "AWS Fargate is a serverless compute engine for containers th
Learn more [here](https://aws.amazon.com/fargate)
</b></details>
#### AWS Storage
#### AWS - S3
<details>
<summary>Explain what is AWS S3?</summary><br><b>
@ -910,7 +938,6 @@ Storage classes offered today:
* have 9x9% durability
More on storage classes [here](https://aws.amazon.com/s3/storage-classes)
</b></details>
<details>
@ -988,14 +1015,6 @@ Learn more [here](https://docs.aws.amazon.com/AmazonS3/latest/dev/transfer-accel
<summary>What storage options are there for EC2 Instances?</summary><br><b>
</b></details>
<details>
<summary>What is AWS Snowmobile?</summary><br><b>
"AWS Snowmobile is an Exabyte-scale data transfer service used to move extremely large amounts of data to AWS."
Learn more [here](https://aws.amazon.com/snowmobile)
</b></details>
#### AWS Disaster Recovery
<details>
@ -1056,23 +1075,92 @@ True
A transport solution which was designed for transferring large amounts of data (petabyte-scale) into and out the AWS cloud.
</b></details>
##### AWS ELB
#### AWS - ELB
<details>
<summary>What is ELB (Elastic Load Balancing)?</summary><br><b>
AWS definition: "Elastic Load Balancing automatically distributes incoming application traffic across multiple targets, such as Amazon EC2 instances, containers, IP addresses, and Lambda functions."
[AWS Docs](https://aws.amazon.com/elasticloadbalancing): "Elastic Load Balancing automatically distributes incoming application traffic across multiple targets, such as Amazon EC2 instances, containers, IP addresses, and Lambda functions."
</b></details>
More on ELB [here](https://aws.amazon.com/elasticloadbalancing)
<details>
<summary>True or False? Elastic Load Balancer is a managed resource (= AWS takes care of it)</summary><br><b>
True. AWS responsible for making sure ELB is operational and takes care of lifecycle operations like upgrades, maintenance and high availability.
</b></details>
<details>
<summary>What types of AWS load balancers are there?</summary><br><b>
* Classic Load Balancer (CLB): Mainly for TCP (layer 4) and HTTP, HTTPS (layer 7)
* Application Load Balancer (ALB): Mainly for HTTP, HTTPS and WebSocket
* Network Load Balancer (NLB): Mainly for TCP, TLS and UDP
* Gateway Load Balancer (GWLB): Mainly for layer 3 operations (IP protocol)
</b></details>
<details>
<summary>Which load balancer would you use for services which use HTTP or HTTPS traffic?</summary><br><b>
Application Load Balancer (ALB).
</b></details>
<details>
<summary>True or False? With ALB (Application Load Balancer) it's possible to do routing based on query string and/or headers</summary><br><b>
True.
</b></details>
<details>
<summary>Explain "health checks" in the context of AWS ELB</summary><br><b>
Health checks used by ELB to check whether EC2 instance(s) are properly working.<br>
If health checks fail, ELB knows to not forward traffic to that specific EC2 instance where the health checks failed.
</b></details>
<details>
<summary>True or False? AWS ELB health checks are done on a port and a route</summary><br><b>
True.
For example, port `2017` and endpoint `/health`.
</b></details>
<details>
<summary>What types of load balancers are supported in EC2 and what are they used for?</summary><br><b>
* Application LB - layer 7 traffic
* Network LB - ultra-high performances or static IP address (layer 4)
* Classic LB - low costs, good for test or dev environments (retired by August 15, 2022)
* Gateway LB - transparent network gateway and and distributes traffic such as firewalls, intrusion detection and prevention systems, and deep packet inspection systems. (layer 3)
* Application LB - layer 7 traffic<br>
* Network LB - ultra-high performances or static IP address (layer 4)<br>
* Classic LB - low costs, good for test or dev environments (retired by August 15, 2022)<br>
* Gateway LB - transparent network gateway and and distributes traffic such as firewalls, intrusion detection and prevention systems, and deep packet inspection systems. (layer 3)<br>
</b></details>
<details>
<summary>Which type of AWS load balancer is used in the following drawing?<br>
<img src="images/aws/identify_load_balancer.png" width="300x;" height="400px;"/>
</summary><br><b>
Application Load Balancer (routing based on different endpoints + HTTP is used).
</b></details>
<details>
<summary>What are possible target groups for ALB (Application Load Balancer)?</summary><br><b>
* EC2 tasks
* ECS instances
* Lambda functions
* IP Addresses
</b></details>
<details>
<summary>True or False? ALB can route only to a single route group</summary><br><b>
False. ALB can route to multiple target groups.
</b></details>
<details>
<summary>True or False? Network load balancers operate in layer 4</summary><br><b>
True. They forward TCP, UDP traffic.
</b></details>
#### AWS Security
@ -1915,6 +2003,14 @@ Amazon definition: "AWS OpsWorks is a configuration management service that prov
Learn more about it [here](https://aws.amazon.com/opsworks)
</b></details>
<details>
<summary>What is AWS Snowmobile?</summary><br><b>
"AWS Snowmobile is an Exabyte-scale data transfer service used to move extremely large amounts of data to AWS."
Learn more [here](https://aws.amazon.com/snowmobile)
</b></details>
<details>
<summary>What is AWS Athena?</summary><br><b>
@ -2026,6 +2122,15 @@ AWS definition: "Amazon Simple Queue Service (SQS) is a fully managed message qu
Learn more about it [here](https://aws.amazon.com/sqs)
</b></details>
#### AWS - High Availability
<details>
<summary>What high availability means from AWS perspective?</summary><br><b>
* Application/Service is running in at least 2 availability zones
* Application/Service should survive (= operate as usual) a data center disaster
</b></details>
#### AWS - Production
<details>
@ -2042,8 +2147,36 @@ One way is through launching a new instance. In more detail:
...
</b></details>
<details>
<summary>You try to use an detached EBS volume from us-east-1b in us-east-1a, but it fails. What might be the reason?</summary><br><b>
EBS volumes are locked to a specific availability zone. To use them in another availability zone, you need to take a snapshot and restore it in the destination availability zone.
</b></details>
<details>
<summary>When you launch EC2 instances, it takes them time to boot due to commands you run with user data. How to improve instances boot time?</summary><br><b>
Consider creating customized AMI with the commands from user data already executed there. This will allow you launch instance instantly.
</b></details>
<details>
<summary>You try to mount EFS on your EC2 instance and it doesn't work (hangs...) What might be a possible reason?</summary><br><b>
Security group isn't attached to your EFS or it lacks a rule to allow NFS traffic.
</b></details>
<details>
<summary>How to migrate an EBS volume across availability zones?</summary><br><b>
1. Pause the application
2. Take a snapshot of the EBS volume
3. Restore the snapshot in another availability zone
</b></details>
<details>
<summary>How to encrypt an unencrypted EBS volume attached to an EC2 instance?</summary><br><b>
1. Create EBS snapshot of the volume
2. Copy the snapshot and mark the "Encrypt" option
3. Create a new EBS volume out of the encrypted snapshot
</b></details>

View File

@ -0,0 +1,15 @@
## AWS ELB - ALB Multiple Target Groups
### Requirements
Two EC2 instances with a simple web application that shows the web page with the string "Hey, it's a me, `<HOSTNAME>`!"
One EC2 instance with a simple web application that shows the web page with the string "Hey, it's only a test..." under the endpoint /test
### Objectives
1. Create an application load balancer for the two instances you have, with the following properties
1. healthy threshold: 3
2. unhealthy threshold: 3
3. interval: 10 seconds
2. Create another target group
1. Traffic should be forwarded to this group based on the "/test" path

View File

@ -0,0 +1,13 @@
## AWS ELB - Application Load Balancer
### Requirements
Two EC2 instances with a simple web application that shows the web page with the string "Hey, it's a me, `<HOSTNAME>`!"
### Objectives
1. Create an application load balancer for the two instances you have, with the following properties
1. healthy threshold: 3
2. unhealthy threshold: 3
3. interval: 10 seconds
2. Verify load balancer is working (= you get reply from both instances at different times)

View File

@ -0,0 +1,12 @@
## AWS - Create EFS
### Requirements
Two EC2 instances in different availability zones
### Objectives
1. Create an EFS with the following properties
1. Set lifecycle management to 60 days
2. The mode should match a use case of scaling to high levels of throughput and I/O operations per second
2. Mount the EFS in both of your EC2 instances

View File

@ -0,0 +1,44 @@
## AWS ELB - ALB Multiple Target Groups
### Requirements
Two EC2 instances with a simple web application that shows the web page with the string "Hey, it's a me, `<HOSTNAME>`!"
One EC2 instance with a simple web application that shows the web page with the string "Hey, it's only a test..." under the endpoint /test
### Objectives
1. Create an application load balancer for the two instances you have, with the following properties
1. healthy threshold: 3
2. unhealthy threshold: 3
3. interval: 10 seconds
2. Create another target group
1. Traffic should be forwarded to this group based on the "/test" path
### Solution
#### Console
1. Go to EC2 service
2. Click in the left side menu on "Load balancers" under "Load balancing"
3. Click on "Create load balancer"
4. Choose "Application Load Balancer"
5. Insert a name for the LB
6. Choose an AZ where you want the LB to operate
7. Choose a security group
8. Under "Listeners and routing" click on "Create target group" and choose "Instances"
1. Provide a name for the target group
2. Set healthy threshold to 3
3. Set unhealthy threshold to 3
4. Set interval to 10 seconds
5. Click on "Next" and choose two out of three instances you've created
6. Click on "Create target group"
9. Refresh target groups and choose the one you've just created
10. Click on "Create load balancer" and wait for it to be provisioned
11. In the left side menu click on "Target Groups" under "Load Balancing"
12. Click on "Create target group"
13. Set it with the same properties as previous target group but this time, add the third instance that you didn't include in the previous target group
14. Go back to your ALB and under "Listeners" click on "Edit rules" under your current listener
1. Add a rule where if the path is "/test" then traffic should be forwarded to the second target group you've created
2. Click on "Save"
15. Test it by going to the browser, insert the address and add "/test" to the address

View File

@ -0,0 +1,35 @@
## AWS ELB - Application Load Balancer
### Requirements
Two EC2 instances with a simple web application that shows the web page with the string "Hey, it's a me, `<HOSTNAME>`!"
### Objectives
1. Create an application load balancer for the two instances you have, with the following properties
1. healthy threshold: 3
2. unhealthy threshold: 3
3. interval: 10 seconds
2. Verify load balancer is working (= you get reply from both instances at different times)
### Solution
#### Console
1. Go to EC2 service
2. Click in the left side menu on "Load balancers" under "Load balancing"
3. Click on "Create load balancer"
4. Choose "Application Load Balancer"
5. Insert a name for the LB
6. Choose an AZ where you want the LB to operate
7. Choose a security group
8. Under "Listeners and routing" click on "Create target group" and choose "Instances"
1. Provide a name for the target group
2. Set healthy threshold to 3
3. Set unhealthy threshold to 3
4. Set interval to 10 seconds
5. Click on "Next" and choose the two of the instances you've created
6. Click on "Create target group"
9. Refresh target groups and choose the one you've just created
10. Click on "Create load balancer" and wait for it to be provisioned
11. Copy DNS address and paste it in the browser. If you refresh, you should see different message based on the instance where the traffic was routed to

View File

@ -0,0 +1,27 @@
## AWS - Create EFS
### Requirements
Two EC2 instances in different availability zones
### Objectives
1. Create an EFS with the following properties
1. Set lifecycle management to 60 days
2. The mode should match a use case of scaling to high levels of throughput and I/O operations per second
2. Mount the EFS in both of your EC2 instances
### Solution
1. Go to EFS console
2. Click on "Create file system"
3. Create on "customize"
1. Set lifecycle management to "60 days since last access"
2. Set Performance mode to "MAX I/O" due to the requirement of "Scaling to high levels of throughput"
3. Click on "Next"
4. Choose security group to attach (if you don't have any, create one and make sure it has a rule to allow NFS traffic) and click on "Next" until you are able to review and create it
5. SSH into your EC2 instances
1. Run `sudo yum install -y amazon-efs-utils`
2. Run `mkdir efs`
3. If you go to your EFS page and click on "Attach", you can see what ways are there to mount your EFS on your instancess
1. The command to mount the EFS should be similar to `sudo mount -t efs -o tls <EFS name>:/ efs` - copy and paste it in your ec2 instance's OS

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB