2. What is a three-tier
architecture?
A three-tier application is a type of software
architecture that divides an application into three
logical layers: presentation, application (or logic), and
data. Each layer serves a specific purpose and
communicates with the other layers to perform
various functions within the application.
1.
3. Parts of a three-tier
architecture
Presentation Tier (Front-end)
This layer is responsible for handling user interactions
and displaying information to users.
It includes user interfaces, such as web pages, mobile
apps, or desktop interfaces.
The presentation tier communicates with the
application tier to request and receive data, but it
doesn't directly interact with the data storage.
2.
4. Parts of a three-tier
architecture
Application Tier (Middle-tier or Logic Tier)
This layer contains the core logic and functionality of the
application.
It processes user requests from the presentation tier,
executes business logic, and interacts with the data tier to
retrieve or update data.
The application tier acts as an intermediary between the
presentation tier and the data tier, ensuring separation of
concerns and modularity.
3.
5. Parts of a three-tier
architecture
Data Tier (Back-end)
This layer manages the storage and retrieval of data used
by the application.
It typically consists of databases or other data storage
systems.
The data tier stores and organizes data, handles data
retrieval and manipulation requests from the application
tier, and ensures data integrity and security.
4.
8. On your AWS Console, Search for 'VPC', Click on create VPC.
Now, on the 'VPC Settings' option, select 'VPC and more', go to Name tag option
and put in a VPC name, Lets leave the IPv4 CIDR Block at default for this project
7.
9. 8.
Select [No ipv6 CIDR Block], Leave the [tenancy] at default, in this case we are
using 2 availiability zones which we are going to set as [us-east-1a] and [us-east-1b]
10. 9.
Set [Public Subnet] at 2, [Private Subnets] at 4 which makes a total of 6 subnets for
the 2 availability zones. Now, leave the [NAT Gateway] at none in this case
12. 11.
Select these Options and click on the create [VPC button] when done.
Now, after VPC Parameters is created, click on the [View VPC] Button
13. 12.
Your VPC should be created like this showing the parameters.
You could also Check the [Resource map] to view your created VPC.
14. 13.
Now, lets enable Auto asign Public IPv4 address in both public subnets, this is
necessary so our application can be accessed publicly. Click on Subnets - Select
Subnet ID - Click on Actions - Select Edit Subnet Settings
15. 14.
Now, Check the Enable auto assign public IPv4 address box -
Scroll Down and Click Save. Now repeat the same action for the
other Public Subnet
22. 21.
Scroll to Application and OS images AMI - Select Amazon Linux -
Select Amazon Linux 2 Free Tier Instance type
23. 22.
Scroll to Instance type - Click rop down arrow - Select t2 micro - Scroll
to key pair login - Select Create new key pair
24. 23.
Type in Keypair name - Click on Create Key Pair
(Make sure you save yo
ur downloaded keypair in a secure place )
25. 24.
Now, lets create our security groups - Scroll to Network Settings - Select Create
Security Groups - Input Name - Input Description - Select our created VPC
26. 25.
Click Add Security Group Rule - Under Type select All ICMP IPv4 - For source
type, we are selecting Anywhere for this project - Now lets add another
Security Group Rule click on it.
27. 26.
Now perform the same procedure but this time setting the type at HTTP. Now
click on add Security Group Rule again for the 3rd one
C
28. 27.
This time set the type to SSH - Click Advance Network Configuration - Click
Add Network Interface
30. 29.
Now Scroll down to user data and paste the bash script as seen (I'll leave the
Bash script in the N
ext Page, modify as you wish) - Click Launch Template
43. 42.
Now, Give a Security Group Name - Same as Description - Select your VPC -
Set inbound rules as clicking Add rule - Select Type as indicated and select
source as anywhere IPv4
44. 43.
Click Create Security Group - Now return to your ALB Settings and update the security
group to the just created one NB: if it doesnt come up, refresh with the Refresh Icon
45. 44.
Scroll to Listeners and routing - Select your Created Target Group - Scroll down
and Click Create Load Balancer - Click Veiw Load Balancer to see
46. 45.
Give a few minutes for the provisioning process to be completed for the Load
Balancer to be Active - Go back to youe EC2 - Auto Scaling Groups step 3 and click on
Attach to an existing load balancer View page 33 -35 if you've forgotten the steps
47. 46.
Select your already Existing Load Balancer target group - Turn on Elastic Load
Balancing health checks - Scroll Down and Click Next
49. 48.
Set limits on how much your desired capacity can be increased or decreased as seen
- select Target tracking scaling policy
50. 49.
Set limits on how much your desired capacity can be increased or decreased as seen
- select Target tracking scaling policy - Scroll down and Click on Next - Keep clicking next
till you get to the Review Page - At the Review page, scroll down and Click Create auto
scaling group
51. 50.
Now we have our ASG Created Sucessfully. Weldone! Now we have 2 instances running. to
confirm this, go to your EC2 - select instances to view how many instances are running.
52. 51.
You can see the two instances are running - Now Copy the Public IPv4 IP address, create a new
tab on your browser and paste to check if the website loads from the instance. Do the same for
the other instance.
53. 52.
The IP Address Opens up the website - Click on the Link to Open up the Site
54. 53.
Paste the DNS Name in your Browser to access the site through the LB
55. 54.
Now, Lets Create the app tier - Go to EC2 - Launch
template - Enter template name - enter template
version description - Click on Auto Scaling Guidance -
Go to AMI - Select Amazon Linux - Select Amazon Linux
2 free tier - for instance type Select t2 micro - for key
pair, select the existing key pair we created at the
beginning - Click create security group - Give a security
group name - put description - for VPC use the one we
created - Click add security group rule - For type select
Custom ICMP IPv4 - For source type, select Anywhere -
Click on Add security group rule again - this time for
type click on SSH - Source type is Custom - for source,
select your Webtier security group - Click on Create
Launch Template - click launch template
57. 56.
Now lets create the Back-end auto scaling Group - Click
on the Hamburger Sign go to Auto scaling group -
input Auto scaling group name - Select Our Launch
template for the App tier - under version click Latest -
Click Next - Now for Network Chose Our VPC - Under
AZ and Subnets, Select (Us east 1a) private 1 subnet and
(Us east 1b) private 2 subnet - Click Next - on Load
Balancing, Click attach to an existing Load Balancer -
for this, lets duplicate our tab, go to Load Balancing -
Target groups - instances - give target group name -
scroll down to VPC and select our VPC - Click on Next
58. 57.
Scroll down and click on Create target group - Now go
to Load Balancer - Click Create Load Balancer - on the
load Balancer type click create button on ALB - input
Load Balancer name - on scheme, select internal - Go to
network mapping and select our VPC - on mappings,
make sure you select the private subnets for the app
tier - Go to security group - click on the create a new
security group link - input name - input description -
select our VPC - click on inbound rules - for type click
HTTP
59. 58.
- for Source select Custom and Search for the Security
group ID of the web tier and select that - CLICK add
rule again - for type click All ICMP IPv4 - for Source
select Custom and Search for the Security group ID of
the web tier and select that
- Scroll down and Click Create Security Group - Go back
to the Application Load Balancer page - on Security
group option click on the refresh icon on the right, now
click the drop down arrow and select our just created
security group for the app tier - on Listeners and
routing go to default action click the drop down arrow
and click on the created target group - Scroll down
amd click on Create Load Balancer
60. 59.
Now lets go to Our Auto Scaling Group Page - existing
load Balancer target groups - click the refresh icon -
click the drop down icon and select our created target
group for the App tier - Enable Health Checks - Click on
Next - Now on Configure group size and scaling policies
- desired capacity 2 - minimum capacity 2 - Maximum
Capacity 4 - Now go to Automatic Scaling - select
Target tracking Scaling policy - Scroll down and Keep
Clicking on Next till you get to the Review page - Scroll
down and click on Create Auto Scaling group - you
should see it successfully created. Now you should See
4 total instances when you go to your EC2 instances.
64. 63.
Now, for Availability Zones Click us east 1a and us east 1b -
Under Subnets Choose the private subnets assigned for
database tier which on my case is private subnet 3 and 4 -
Now, click Create - Now click on Databases - Click on Create
Database - on the Engine Options select MySQL engine - Scroll
to Template and Click Free Tier option - Scroll down and Give
Database name (DB instance identifier) - scroll down and input
master password - on the instance configuration area, I'll
chose a t2 micro - Scroll down, Enable auto scaling - Change
the VPV to our created VPC - Scroll down to VPC Security
group firewall - click create new - enter VPC Security group
name - Select Availability Zone as us east 1a (the other
automatically acts as a standby) - Scroll down and Click on
Create Database
65. 64.
Now go to your EC2 console go to Security Groups - Locate the Database
Security group - click inbound rules - click edit inbo
und rules
66. 65.
Click on add rule - Set the type to
All traffic - Set the Source to
Custom, search and select out our
Database Security group - Click
Create security group rule.
67. 66.
Now you can test by Pinging any of the private instances through
the public instances using EC2 instance connect, Gitbash etc