DEV Community

Cover image for AWS- How to Storage
Hootan
Hootan

Posted on

AWS- How to Storage

EBS Volumes are created for a specific AZ. It is possible to migrate them between different AZs using EBS Snapshots.

By default, the Root volume type will be deleted as its "Delete On Termination" attribute checked by default. Any other EBS volume types will not be deleted as its "Delete On Termination" attribute disabled by default.

MIs are built for a specific AWS Region, they're unique for each AWS Region. You can't launch an EC2 instance using an AMI in another AWS Region, but you can copy the AMI to the target AWS Region and then use it to create your EC2 instances.

When creating EC2 instances, you can only use the following EBS volume types as boot volumes: gp2, gp3, io1, io2, and Magnetic (Standard).

Using EBS Multi-Attach, you can attach the same EBS volume to multiple EC2 instances in the same AZ. Each EC2 instance has full read/write permissions.

EFS is a network file system (NFS) that allows you to mount the same file system on EC2 instances that are in different AZs.

EBS are network drives which makes it provides less I/O performance than Instance Store.

EC2 Instance Store provides the best disk I/O performance.

You are running a high-performance database that requires an IOPS of 310,000 for its underlying storage. What do you recommend?

256,000 is the maximum IOPS you can achieve when you're using the EBS io2 Block Express volume type.

64,000 is the maximum IOPS you can achieve when you're using EBS io1 or io2 volume types.

16,000 is the maximum IOPS you can achieve when you're using the EBS gp2 volume type.

You can run a database on an EC2 instance that uses an Instance Store, but you'll have a problem that the data will be lost if the EC2 instance is stopped (it can be restarted without problems). One solution is that you can set up a replication mechanism on another EC2 instance with an Instance Store to have a standby copy. Another solution is to set up backup mechanisms for your data. It's all up to you how you want to set up your architecture to validate your requirements. In this use case, it's around IOPS, so we have to choose an EC2 Instance Store.

provisioned volumes greate for data base worload wich sensetive to storage performance and consistancy.

Storage Classes

Tier List
Regional frequently accessed files
Infrequent Access: Low price and cost to retrieve files
One zone: greate for dev and backup by default.
In compatible: 90% discount.

Availablity and Durability
Regional: multi AZ and greate for production

EFS

Go to EFS console and click on "create filesystem" button
click on "customize" button.
name it

mnt/efs/fs1 How to create a file in?

sudo su 
echo ---------- > ---------/--------
cat --------/--------
Enter fullscreen mode Exit fullscreen mode

means into
/ means use this filename
cat means it will read the filed for you

EBS vs EFS

Delete AMI image
high Availablity and Scailablity:ELB&ASG

Vertical scalablity=> switch to the better instance
Horizontal scalablity=> use number of instances
Hight Availability=> use multi AZ servers for backup

What is load balancing

forward user trafic into the server

Types of load balancer:

  1. classic load Balancer(CLB)
  2. Application load balancer(ALB)
  3. Network load balancer(NLB)
  4. Getway load balancer(GLB)

    -> load | security ->
    user <- balancer | groups <- EC2

0.0.0/0 eg.IP 80 sg.-----
any IP

Advanced Load blancer

Network Security

-create a security group named launch-wizard-1 with the rules of:

  • SSH - custom ::/0
  • SSH - custom 0.0.0.0/0
  • HTTP - [Security group of load balancer]

How to creat a Load Balancer?
launch 2 instances:

  1. My first instance
  2. my second instance

without key pair and the security group named launch-wizard-1

which allowed as to do HTTP traffic and SSH trafic into our EC2 instance.

Create a load balancer(ALB)
name it to: DemoALB
check the all AZ's
open another tab and create new security group:
name it to: Demo-sg-load-balancer
Description: Allow HTTp into ALB
HTTP 0.0.0.0/0

back to previus tab remove the default security group and add Demo-sg-load-balancer.
open another tab and create new target group:
name it to: demo-tg-alb
check both instances and include pending below.

back to previus tab add the target group demo-tg-alb
and done.

Load balancer ruls

click on your load balancer
under listeners click on HTTP:80

add rule

  • name it into: DEmo rule
  • on add conditions (path-> /eror)
  • fixed response
  • code:404
  • response: not found, custom errore!

creating NLB
name it into: DemoNLB
take every AZ's
create security group:

  • Demo-sg-nlb
  • Demo sg for nlb
  • HTTP 0.0.0.0/0 attach the security group for the listeners create a target group:
  • name it: Demo-tg-nlb
  • protocol: TCP port:80
  • health check: HTTP
  • Advanced health check setting: healthy thresholds:2 timeout:2 interval:5 check all include as pending bellow add demo-tg-nlb to the listener

application load balancer
cross-zon load balancing is enable by default
no charges in this one

network load balancer & getway load balancer is exactly opposite of application load balacer.

to enable cross-zon load balancing
click on the load balancer: go on "attributes" tab; click on "edite" btn and check the "m cross-zon load balancing"

client ---> load
<--- balacer
SSl/TLS
it will encrypt the traffic.

to enable it:
go to the load balancer click on the load balancer name, scroll down click on "add listener" btn. change the protocol from HTTP to HTTPS the action would be forward the spacific target group.

In the Network load balacer you have to change protocol to TLS.

Deregistration delay or connection Draining
Time to complete "in-flight-request" while the instance is de-registering or unhealthy.
It takes between 1 to 3600 seconds in default it's 300 seconds.

*auto scaling group *
atomaticaly it scals up or down in the situation.

ASG
minimum capacity, desired capacity, maximum cpacity
it will scal ou or in for you.

Elasric load balancer automaticaly with health check method since it self to the auto scaling group instance.

Cloude watch alarms & scailing

This is a metric that you specify such as avarage CPU, custom metric to Scali your instances.

how to run it

click on "auto scaling group" then click on "create auto scaling group"

  1. name it
  2. create
  3. launch template
  4. and then link it
  5. launch a tamplate: with a keypair and security group and in the advanced detail write the user data.
  6. select al AZ's
  7. attach to an existing load balancer
  8. select your target group
  9. enable ELB
  10. create

scaling policies hands on

EC2>auto scaling groups>DemoASG

go on Dynamic scaling polices and click on create:

  1. target tracking policy
  2. target value:40
  3. create

go on details tab and click on edit on the group size:

  1. Max:3
  2. create

go on "instance management" tab click on instance name and click on "connect"
search "instance stress amazon Linux" on google and open the gist.github page.
copy the first command in the instance and copy the second command for the installing "stress"
to run the stress write:

stress -c 4
Enter fullscreen mode Exit fullscreen mode

Top comments (0)