46. 3 Tier Architecture - Ayushi-srivastav/OCI GitHub Wiki
A 3-tier architecture is a design pattern that divides an application into three layers or tiers: the presentation tier, the application tier, and the data tier. Each tier is responsible for specific tasks and interacts with the other tiers to provide a complete application.
1.Presentation Tier (Client Tier)
This is the topmost layer of the application.
It is responsible for the user interface and user interactions.
Examples: Web browsers, mobile applications, desktop applications.
2.Application Tier (Logic Tier)
This is the middle layer of the application.
It contains the core functionality and business logic.
It processes user requests, performs calculations, and enforces business rules.
Examples: Application servers running backend code (e.g., Node.js, Java Spring, ASP.NET).
3. Data Tier (Database Tier)
This is the bottom layer of the application.
It is responsible for managing and storing the application's data.
Examples: Databases, data storage systems (e.g., MySQL, PostgreSQL, Oracle).
Example Setup in Oracle Cloud Infrastructure (OCI)
Presentation Tier: The client (e.g., web browser) interacts with the application through a load balancer.
Application Tier: The load balancer distributes traffic to multiple application servers in a private subnet.
Data Tier: The application servers interact with a database server in another private subnet to store and retrieve data.
Here is a diagram to illustrate the 3-tier architecture setup:
+-------------+
| User |
| Interface |
+-------------+
|
v
+-------------+
| Load |
| Balancer |
+-------------+
|
-----------------
| |
v v
+-------------+ +-------------+
| App Server | | App Server |
| (Private) | | (Private) |
+-------------+ +-------------+
|
v
+-------------+
| Database |
| Server |
| (Private) |
+-------------+
Steps to Implement the 3-Tier Architecture in OCI
1.Create a Virtual Cloud Network (VCN)
Define a VCN with CIDR block (e.g., 10.0.0.0/16).
2.Create Subnets
Public Subnet: For the load balancer (e.g., 10.0.1.0/24).
Private Subnet: For the application servers (e.g., 10.0.2.0/24).
Private Subnet: For the database server (e.g., 10.0.3.0/24).
3.Create Security Lists
Define security rules to allow communication between tiers.
4.Launch Application Servers
Create compute instances in the private subnet for the application tier.
5.Create a Load Balancer
Create a load balancer in the public subnet.
Add application servers as backend servers.
6.Launch Database Server
Create a database instance in the private subnet for the data tier.
7.Set Up Horizontal Scaling
Configure auto-scaling for the application servers based on demand.
Conclusion
The 3-tier architecture provides a scalable, maintainable, and secure way to design applications. By separating concerns into different tiers, you can manage and scale each tier independently, leading to a more robust and flexible infrastructure.