High Availability Architecture with AWS CLI

What is mean by HIGH AVAILABILITY Architecture ?

Each time while we create a web page, we will put them in server, it will respond to the user’s request. Maintaining the the servers become more crucial part, since it must to be present all time i.e. 24 x 7, it must to more reliable, durable and available.

Problems i.e. crash of server’s hardware, natural disaster, virus attack can affect the web page. So the page will not able to access by user. But the active webpage should be present always since from the deployment. If not user will not have good opinion on your site. So, availability of your web page should be high, it must to be tend to 100% (99.99… %).

Some of the ways to increase the avalability and durability while deploying the server in EC2 instance are:

we can create EBS volume, mount the EBS volume in the root directory of web server. This increase the availability since, whenever the server crashes, we can remove the EBS volume from that instance and transfer that volume to another new instance without losing the availabilty of Web Page.

But here we will face a problem while the problem arise in availability zone then EBS volume also get affected. This case arises more rarely but we want to make the structure more reliable. So we want to make some remedies. The program files can be recreated but when it comes to static data like images, etc need to be available since it is difficult to recreate it. So we want alternative storage system for static data.

The alternative storage system is object storage system provide by AWS is S3 service, this comes with full managed and makes highest durability perecentage of 99.999999999 %. It is know serverless storage.

In S3, we can put all our static data. Thus this data will be more durable and we can use this data in our webpage, that will available all time.

Then to improve the speed of transfering data and attain low latency we have to cloudfront, which will creating a cache at edge locations. Then when next time request occurs, it will take to the Availability zone instead it fetches the data in nearby edge location. It works on CDN (Content Delivery Network).

Architecture is a framework or structure, here were using build an architecture based on EC2, then on top of this connecting EBS, putting the static data in S3 and making them available in edge location using cloudfrount via CDN.

Task Description:

Create an architecture using CLI includes-

  • Webserver configured on EC2 Instance
  • Document Root(/var/www/html) made persistent by mounting on EBS Block Device.
  • Static objects used in code such as pictures stored in S3
  • Setting up Content Delivery Network using CloudFront and using the origin domain as S3 bucket.
  • Finally place the Cloud Front URL on the webapp code for security and low latency.

To start with first we want to create EC2 instance and EBS volume, then we want to attach EBS to that instance. To Know about it you can see my another article related to it, which I mentioned below.

Now let us get into our task:

Webserver configured on EC2 Instance

To Configure Web Server First we need check if Webserver is installed or not for that CMD is : “rpm -q httpd”.

After that if it is not Installed then to Install we use CMD is : “yum install httpd”

Then we want to Start Web Server

systemctl start httpd

To Make it permanent

systemctl enable httpd

Web Server is Configured

EBS VOLUME To Document Root(/var/www/html) Directory

To add any storage appliance we want follow fixed steps. First of all, when we buy any appliance, it is always a physical device. We want to follow the steps to make it usable in our machine.

Steps are:

  1. Partition
  2. Format
  3. Mount

After taking partition on EBS volume and formating the volume. We can mount that partition with Document Root(/var/www/html). For that CMD is :

mount /dev/xvdf1 /var/www/html

S3 Bucket With a Unique Name In The Region

It is a object storage. It has high durability and easily accessible globally.

we want to Create a S3 Bucket Using CLI. S3 bucket you can create in any region but more feasible it to check your nearest region where you can create.

It help us to put our data in CDN. So, it is easy to create local in edge location.

create S3 bucket :

aws s3api create-bucket — bucket aws-arth-buc123— region us-east-1

Static Objects in S3 Bucket

After that we need to save our image file in S3 Bucket it means we need to Upload The File in S3 Bucket. For That CMD is :

copy image to bucket:

aws s3 cp aws.jpg s3://aws-arth-buc123/Rightarth-task6/

upload: .\aws.jpg to s3://aws-arth-buc123/Rightarth-task6/aws.jpg

Now we need to make that Image File Public. By default it is Private and because of that any other user can’t access that file. So, make it Public.

aws s3api put-object-acl — bucket aws-arth-buc123 — key Rightarth-task6/aws.jpg — acl public-read

Content Delivery Network using Cloud Front and using the origin domain as S3 bucket

Setup Cloud Front:

aws cloudfront create-distribution — origin-domain-name aws-arth-buc123.s3.amazonaws.com — default-root-object Rightarth-task6/aws.jpg

Cloud Front URL on the webapp code

Now the reaches the user with low latency and will be there with high durability.

Thank you


#awscloud #awscli #aws #vimaldaga #righteducation #educationredefine #rightmentor #worldrecordholder #linuxworld #makingindiafutureready #righeudcation #awsbylw #arthbylw

learning things that never get exhausted