Load Balancers in Oracle Cloud Infrastructure (OCI): Types, Differences, and How to Configure
Distribute traffic, improve uptime, and scale easily with OCI load balancers. Learn the differences between HTTP(S) Load Balancer (Layer 7) and Network Load Balancer (Layer 4), and how to configure each.
1. Why Load Balancing Matters
- High availability: failover when a server goes down.
- Scalability: add/remove backends behind the balancer.
- Performance: route users to healthy, responsive servers.
- Security: hide backend IPs; terminate TLS centrally.
2. Load Balancer Types
| Type | Layer | Traffic | Key Features | Ideal For |
|---|---|---|---|---|
| Network Load Balancer (NLB) | L4 | TCP/UDP | High throughput, low latency, pass-through | Non-HTTP protocols, DB proxying, custom TCP/UDP |
| HTTP(S) Load Balancer | L7 | HTTP/HTTPS | SSL termination, URL routing, headers, cookies | Websites, REST APIs, web apps |
3. HTTP(S) Load Balancer
Understands HTTP, can terminate TLS, route by path/host, and handle cookie persistence.
- Use when: serving websites/APIs on 80/443, need TLS offload or path routing.
- Pros: built-in certs, smart routing, session stickiness, native monitoring.
4. Network Load Balancer
Fast, low-latency L4 balancing for any TCP/UDP protocol. No TLS termination or content inspection.
- Use when: custom protocols, raw performance, DB proxies, gaming/IoT.
- Pros: extremely performant, static IPs, minimal config overhead.
5. Shared Concepts
- Backend Set: group of backend servers.
- Backends: individual instances.
- Health Checks: HTTP/TCP tests for availability.
- Listener: protocol/port definition.
- Routing Policies: (HTTP LBs) path/host rules.
- Shape: throughput capacity (flexible/fixed).
6. Create an HTTP(S) Load Balancer
- Networking → Load Balancers → Create (Public or Private).
- Backend Set: round robin; health check
GET /healthevery ~10s; add backend IPs. - Listener: HTTP 80 or HTTPS 443; attach certificate for TLS.
- Create: use the provided public IP; map DNS accordingly.
7. Create a Network Load Balancer
- Networking → Network Load Balancers → Create (Public/Private).
- Listener: TCP/UDP and port (e.g., 3306 for MySQL).
- Backend Set: backends + TCP health checks.
- Create: point clients at the NLB IP.
8. Best Practices
- Spread backends across multiple ADs.
- Use lightweight health checks (simple endpoints).
- Terminate TLS at the HTTP LB for simpler cert ops.
- Enable Monitoring & Logging.
- Right-size shapes and automate with Terraform.
9. Example Architecture
Two web VMs across AD-1/AD-2 behind an HTTPS LB; private MySQL in a private subnet; DNS points to LB IP; health check /health every 5 seconds.
10. Summary
Choose HTTP(S) LB for web/API features (TLS offload, routing) or NLB for raw L4 performance. Either way, OCI makes high-availability and scaling straightforward.