Home » Network Load Balancing: L4 vs L7, ADC, GSLB, Health Checks และ Algorithms
Network Load Balancing: L4 vs L7, ADC, GSLB, Health Checks และ Algorithms
Network Load Balancing: L4 vs L7, ADC, GSLB, Health Checks และ Algorithms
Load Balancing กระจาย traffic ไปยัง backend servers หลายตัวเพื่อ high availability และ scalability L4 Load Balancing ทำงานที่ transport layer (TCP/UDP), L7 ทำงานที่ application layer (HTTP/HTTPS) พร้อม content-based routing, ADC (Application Delivery Controller) รวม load balancing + SSL offload + WAF + caching, GSLB (Global Server Load Balancing) กระจาย traffic ข้าม data centers ทั่วโลก
Single server มี capacity จำกัด และเป็น single point of failure Load balancer แก้ทั้งสองปัญหา: กระจาย requests ไปหลาย servers (scale out) + ตรวจสอบ health ของ servers (ถ้า server ตาย → เอาออก → traffic ไป servers ที่เหลือ) ทำให้ application มี high availability และ horizontal scalability
L4 vs L7 Load Balancing
| Feature |
L4 (Transport) |
L7 (Application) |
| Layer |
TCP/UDP (IP + Port) |
HTTP/HTTPS (URL, headers, cookies) |
| Decision Based On |
Source/dest IP, port |
URL path, hostname, headers, cookies, content |
| Performance |
Very fast (simple packet forwarding) |
Slower (must parse application data) |
| SSL Termination |
No (pass-through) |
Yes (terminate SSL, inspect content) |
| Content Routing |
No |
Yes (route /api to API servers, /static to CDN) |
| Session Persistence |
Source IP hash |
Cookie-based, header-based (more flexible) |
| Use Case |
TCP services (database, mail, gaming) |
Web applications (HTTP/HTTPS) |
Load Balancing Algorithms
| Algorithm |
How It Works |
Best For |
| Round Robin |
วนรอบ server 1 → 2 → 3 → 1 → … |
Servers ที่มี capacity เท่ากัน, stateless apps |
| Weighted Round Robin |
Round robin + weight (server แรง = ได้ requests มากกว่า) |
Servers ที่มี capacity ต่างกัน |
| Least Connections |
ส่งไป server ที่มี active connections น้อยสุด |
Long-lived connections (WebSocket, database) |
| Weighted Least Connections |
Least connections + weight |
Mixed server capacities + long connections |
| IP Hash |
Hash source IP → always same server |
Session persistence without cookies |
| Least Response Time |
ส่งไป server ที่ response เร็วสุด |
Performance-sensitive applications |
| Random |
สุ่ม server |
Simple, effective at scale (power of two choices) |
Health Checks
| Type |
How |
Checks |
| TCP Health Check |
TCP connect to port |
Server is listening (port open) |
| HTTP Health Check |
Send HTTP GET → check status code |
Web server is responding (200 OK) |
| HTTPS Health Check |
Send HTTPS GET → check status + cert |
SSL + web server working |
| Custom Script |
Run custom check (query DB, check disk) |
Application-level health (deep check) |
| Passive Check |
Monitor real traffic for errors |
Detect issues from actual user traffic |
Health Check Parameters
| Parameter |
Description |
Typical Value |
| Interval |
ความถี่ในการ check |
5-30 seconds |
| Timeout |
เวลารอ response |
2-5 seconds |
| Unhealthy Threshold |
จำนวน failures ก่อน mark as down |
2-3 consecutive failures |
| Healthy Threshold |
จำนวน successes ก่อน mark as up |
2-3 consecutive successes |
| Check Path |
URL path สำหรับ HTTP check |
/health, /healthz, /status |
ADC (Application Delivery Controller)
| Feature |
รายละเอียด |
| Load Balancing |
L4 + L7 load balancing (core function) |
| SSL/TLS Offload |
Terminate SSL ที่ ADC → backend servers ไม่ต้อง handle SSL |
| WAF |
Web Application Firewall → protect against OWASP Top 10 |
| Caching |
Cache static content → reduce backend load |
| Compression |
Compress HTTP responses (gzip/brotli) → faster delivery |
| Rate Limiting |
Limit requests per client → protect against abuse/DDoS |
| Connection Multiplexing |
Reuse backend connections → reduce connection overhead |
GSLB (Global Server Load Balancing)
| Feature |
รายละเอียด |
| คืออะไร |
Load balance traffic across multiple data centers globally |
| DNS-based |
GSLB ตอบ DNS query ด้วย IP ของ DC ที่ดีที่สุด |
| Proximity |
Route user ไป DC ที่ใกล้ที่สุด (lowest latency) |
| Active-Active |
ทุก DC active → distribute traffic ตาม proximity/load |
| Active-Passive |
Primary DC handles traffic → failover to DR site when primary fails |
| Health Monitoring |
GSLB monitor health ของทุก DC → remove unhealthy DC จาก DNS |
| Solutions |
F5 DNS, Citrix GSLB, AWS Route 53, Cloudflare Load Balancing |
Load Balancer Solutions
| Solution |
Type |
จุดเด่น |
| F5 BIG-IP |
Hardware/Virtual ADC |
Enterprise leader, full ADC features, iRules scripting |
| Citrix ADC (NetScaler) |
Hardware/Virtual ADC |
Strong SSL offload, HDX proxy for Citrix |
| HAProxy |
Software (Open Source) |
Very high performance, widely used, free |
| NGINX Plus |
Software |
Web server + reverse proxy + LB, popular for microservices |
| AWS ALB/NLB |
Cloud-native |
ALB (L7) + NLB (L4), auto-scaling, pay-per-use |
| Envoy |
Software (Open Source) |
Service mesh proxy, gRPC support, observability |
| Traefik |
Software (Open Source) |
Cloud-native, auto-discovery (Docker, K8s), Let’s Encrypt |
ทิ้งท้าย: Load Balancing = High Availability + Scalability
Load Balancing L4: TCP/UDP level (fast, simple) | L7: HTTP level (content routing, SSL offload) Algorithms: round robin, least connections, IP hash, least response time Health checks: TCP/HTTP/custom, interval + threshold → auto-remove unhealthy servers ADC: LB + SSL offload + WAF + caching + compression + rate limiting GSLB: DNS-based multi-DC load balancing (proximity, active-active/passive) Solutions: F5, Citrix, HAProxy, NGINX, AWS ALB/NLB, Envoy, Traefik
อ่านเพิ่มเติมเกี่ยวกับ Network Redundancy HSRP VRRP GLBP และ EVPN-VXLAN Data Center Fabric ที่ siamlancard.com หรือจาก icafeforex.com และ siam2r.com