Creating High Availability Architecture With AWS Command Line Interface

The Architecture includes —

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

Before further proceeding to the practical , lets see the basic terminology that is going to be use in practical………

What is Amazon S3 ?

Amazon S3 is known as Simple Storage service.It is just like Object Storage.It has a simple web services interface that you can use to store and retrieve any amount of data, at any time, from anywhere on the web. It gives any developer access to the same highly scalable, reliable, fast, inexpensive data storage infrastructure that Amazon uses to run its own global network of web sites.The service aims to maximize benefits of scale and to pass those benefits on to developer.Nowadays companies want to collect, store, and analyze their data which is large in amount. Moreover, they want to provide the security to them. The large storage problems bring complexities to the companies and slow down their innovation.It is Designed to provide 99.999999999% durability and 99.99% availability of objects over a given year

Uses Of Amazon S3 :

  1. Data Archiving
  2. Large Data Storage and Analytics
  3. Backup and Recovery
  4. Static Website Hosting

What is Amazon CloudFront?

Amazon CloudFront is a fast content delivery network (CDN) service that securely delivers data, videos, applications, and APIs to customers globally with low latency, high transfer speeds, all within a developer-friendly environment. CloudFront offers a multi-tier cache by default, with regional edge caches that improve latency and lower the load on the origin servers once the item isn’t already cached at the sting. Aws CloudFront use edge location to deliver the content.Aws has 218+ Edge Locations and 12 Regional Edge Caches across the world.

How Content Delivery Network work ?

Lets consider a client from USA wishing to view the content which originates at India-based server.They will experience poor loading times or high latency if this request has to travel across the Atlantic.

To combat this, CDNs store a cached version of your website content in multiple geographical locations around the world, which are known as points of presence. These Point of presence will contain their own caching servers and will be responsible for delivering that content in the user’s location.Over half of the internet’s traffic is served by a content delivery network (CDN). The goal of the CDN is to reduce latency — the delay between submitting a request for a web page and the web page fully loading on your device — by reducing the physical distance that the request has to travel.

Let’s Start with the Practical …….

1.Configure Webserver on EC2 Instance

Step-1 : first configure the AWS CLI with AWS account by providing access key , secret key and choose the region/location of data centre where you want to launch your infrastructure.

Step-2 : After configuring the AWS CLI ,first launch the launch the instance over the AWS cloud .but in my case, it is already launched.you can conform using following command :-

aws ec2 describe-instances

ip-13.233.12.200

Step-3 : Install the “httpd” software on the launched instance.

yum install httpd -y

Step-4 : start the service of httpd.

systemctl start httpd

2.Document Root(/var/www/html) made persistent by mounting on EBS Block Device.

Step-1 : first we create one EBS volume and then we mount the root directory (/var/www/html) with EBS volume to make it persistent.we will keep website data in EBS volume so that if in any case OS get crashed ,then we will not lose the website data.

aws ec2 create-volume --avalability-zone ap-south-1a --size 1

Step-2 : Attach the above created volume with the instance.

aws ec2 atatch-volume --instance-id i-0313e74b2bc622462 --volume-id vol-03479602f9b973534 -device /dev/sdb

Step-3 : Before storing the data,first create partition.

Step-4 : format the partition and mount it with root directory(/var/www/html)

Step-5 : put all the web-pages inside root directory.

index.html

3.Static objects used in code such as pictures stored in S3

Step-1 : First create S3 bucket to store the static object i.e. image,video etc.

aws s3api create-bucket --bucket s3webservicebucket --region ap-south-1 --create-bucket-configuration LocationConstraint=ap-south-1

Step-2 : upload the static content or image to s3 bucket.

verify it through AWS WebUI portal.

4.Setting up Content Delivery Network using CloudFront and using the origin domain as S3 bucket.

Step-1 : Create cloudfront distribution.

aws cloudfront create-distribution --origin-domain-name s3webservicebucket.s3.amazonaws.com

verify it through AWS WebUI

5.Finally place the Cloud Front URL on the webapp code for security and low latency.

Now open the web-browser and search the url — http://13.233.12.200/index.html

and here we have web page output and the image that i am getting is from CloudFront URL(d3r48n27we6ome.cloudfront.net).

Source :-

https://docs.aws.amazon.com

https://data-flair.training/blogs/amazon-cloudfront/