📘 Load Balancer – Complete Concept
📘 Load Balancer – Complete Concept
🔹 1. What is a Load Balancer?
A Load Balancer distributes incoming network traffic across multiple servers to ensure:
- High availability
- Better performance
- No single server overload
👉 Example: Instead of 1 server handling 10,000 users, LB splits traffic across 5 servers.
🔹 2. Why Do We Need It?
Without LB:
- Server crash = whole app down
- Slow response under heavy traffic
With LB:
- Fault tolerance
- Scalability
- High performance
🧠 First: What is IP & Port?
-
IP address = identifies a machine
👉 like house address (192.168.1.1) -
Port = identifies a service inside that machine
👉 like room number - 80 → HTTP
- 443 → HTTPS
- 3306 → MySQL
🔹 3. Types of Load Balancer
(A) Based on Layer (OSI Model)
1. Layer 4 (Transport Level)
- Works on IP + Port
- Faster, less intelligent
- Example: TCP routing
2. Layer 7 (Application Level)
- Works on HTTP/HTTPS
-
Can route based on:
- URL (/login, /payment)
- Headers
- More flexible
(B) Deployment Type
- Hardware LB → Expensive (F5, etc.)
-
Software LB → Common
- NGINX
- HAProxy
- Cloud LB
- AWS Elastic Load Balancing
🔹 4. Load Balancing Algorithms
1. Round Robin
-
Requests distributed one by one
👉 Server1 → Server2 → Server3
2. Least Connections
- Send request to server with fewer active users
3. IP Hash
- Same user always goes to same server
4. Weighted Round Robin
- Powerful servers get more requests
🔹 5. Important Concepts
Health Check
- LB continuously checks servers
- If server is down → stops sending traffic
Auto Scaling
- Add/remove servers automatically based on traffic
SSL Termination
- LB handles HTTPS encryption
- Reduces load on backend servers
Session Persistence (Sticky Sessions)
- Same user → same server
- Useful for login sessions
Comments
Post a Comment