LAB 49 ::‐ Building a Scalable 3‐TIER APPLICATION SETUP with a Load Balancer (Step‐by‐Step Guide.) - guptasanjeev-52/oci_docs GitHub Wiki
In this lab, we will learn how to create a scalable three-tier application in Oracle Cloud Infrastructure (OCI) using a Load Balancer..
A three-tier application has three layers Web Tier , Application Tier , and Database Tier. A Load Balancer distributes incoming user requests across multiple backend servers. This setup improves application availability, traffic distribution, security, and scalability.
What Is a Three-Tier Application?
A Three-Tier Architecture divides an application into three separate layers:
Web Tier: Receives user requests and serves web content.
Application Tier: Processes requests and performs application tasks.
Database Tier: Stores and manages application data.
Each tier has its own responsibility, making the application easier to manage and secure.
What Is a Load Balancer?
A Load Balancer manage your Traffic & distributes incoming network traffic across multiple backend servers. Also gives you a PUBLIC IP (URL) in numbers with the help of this Outside Traffic Can reach to your Application.. For example, if 100 users access a website, the Load Balancer can distribute their requests across two web servers instead of sending every request to just one server. Benefits::- Distributes traffic across multiple servers, Helps prevent one server from becoming overloaded. Improves application availability, Supports scaling by adding more backend servers.
Horizontal Scaling ::- If you have no. of servers for same Application. It means adding more servers (instances) to handle more Traffic or Workload..
Example:- Imagine you have one Shop and Many Customers are Coming. One person Cannot Handle all the Customers at the Same time, So you Open More Counters in the shop and Divide the Work Between Them.. Similarly, In OCI instead of Increasing the power of One server, We add More Servers...
ROUND ROBIN ::- It is a Service Sequence (Weighted Round robin) Giving a Weight or a Priority Number..
It Depends on CPU and RAM on the Servers..
(It's not mandatory, But when the Client Says then Only we Use [Industry level Things])
Least Connection ::- Least Connection is Load Balancing Method That sends a new Request to the Backend Server having the Fewest Active Connections..
IP HASH ::- No use in INDUSTRY..
OCI Components Required..
In this lab, we will use the following OCI components::-
VCN: Creates a private virtual network for our application.
Web Subnet: Hosts the web tier resources.
Application Subnet: Hosts application servers in a private network.
Database Subnet: Hosts database resources in a private network.
Load Balancer: Distributes incoming traffic across web backend servers.
Compute Instances: Run the web and application servers.
Security Lists: Control permitted network traffic.
Internet Gateway: Allows permitted internet traffic to and from public resources.
NAT Gateway: Allows private resources to initiate outbound internet connections without public IP addresses.
Route Tables: Define where network traffic should go.
The exact components and subnet design depend on the lab architecture. A database service may be used instead of a database Compute Instance.
Basic Architecture..
The traffic flow will look like this::
INTERNET USERS
|
v
INTERNET GATEWAY
|
v
LOAD BALANCER
|
+------+------+
| |
v v
WEB SERVER 1 WEB SERVER 2
| |
+------+------+
|
v
APPLICATION TIER
|
v
DATABASE TIER
This is a simplified logical diagram. In the actual OCI configuration, the Load Balancer's placement, subnet configuration, and backend connections depend on the chosen design...
Security Rules
Security List...
1.) WEB SUBNET ::- ( Ingress >> 0.0.0.0/0 // Egress >> App subnet CIDR.)
2.) APPLICATION (App) SUBNET ::- ( Ingress >> Web Subnet CIDR // Egress >> Both Web/Database subnet CIDR.)
3.) DATABASE SUBNET ::- ( Ingress >> App Subnet CIDR // Egress >> App subnet CIDR.)
Gateway...
1.) WEB SUBNET ::- Internet Gateway.
2.) APPLICATION (App) SUBNET ::- NAT / Service Gateway.
3.) DATABASE SUBNET ::- DB is very secure and isolated place. So we don't give any Gateway. Only we give the single Way that reach to the Database with the help of Security List From the Application Subnet Only Traffic Goes their...
We must configure security rules to control traffic between the tiers..
Load Balancer: Allow HTTP or HTTPS traffic from authorized users as required.
Web Tier: Allow incoming application traffic from the Load Balancer.
Application Tier: Allow traffic only from authorized web-tier resources.
Database Tier: Allow database traffic only from authorized application servers.
Private Resources: Use suitable routing for required outbound connections.
The database should not be directly accessible from the public internet.
Load Balancer Traffic Distribution
In this lab, we will configure a Load Balancer with multiple web backend servers. For example: Web Server 1 Web Server 2 The Load Balancer will distribute incoming requests between these servers according to its configured policy. We can also configure health checks to verify whether backend servers are responding correctly. If a backend server becomes unhealthy, the Load Balancer can stop sending requests to it while it remains unhealthy.
Lab Objectives
By completing this lab, we will learn how to: Create a three-tier application architecture in OCI. Configure web, application, and database subnets. Create and configure a Load Balancer. Add multiple backend web servers. Configure backend sets and health checks. Configure security lists and route tables. Test traffic distribution through the Load Balancer. Understand how adding backend servers helps scale an application.
A scalable three-tier application separates the web, application, and database functions into different layers.
In OCI, a Load Balancer distributes incoming requests across multiple backend servers, helping the application handle increased traffic and improving availability.
This lab provides practical experience with networking, security, load balancing, and application scalability in OCI.
STEP-BY-STEP GUIDE...
HUB VCN Rules...
Creating spoke_3tier_vcn in the spoke-network_compartment..
Creating 3 Subnets according to the 3 Tier Architecture..
Creating Seprate-seprate Security List For 3 Subnets..
Now, firstly Creating the Gateway and Route table and then attaching the gateway, route-rules, and security rules to the WEB Subnet Manually.
Adding Manually Created Route Table..
Adding Manually Created Security list to Rules..