On this page
Load balancers
A load balancer spreads incoming requests across a pool of instances and routes around unhealthy ones, giving you a single stable address in front of a changing set of servers.
A load balancer is built from a few parts that fit together. The load balancer itself owns a virtual IP (the VIP) on a subnet. A listener on that VIP accepts traffic for a protocol and port. The listener sends traffic to a pool, and the pool distributes it across its members, your instances, using a load-balancing algorithm. A health monitor continuously checks members and takes unhealthy ones out of rotation.
Patrii Cloud can create the whole chain, load balancer, listener, pool and members, in a single step, so you get a working front end without wiring each part by hand. You can then refine listeners, add health monitors, and layer on Layer-7 policies for content-based routing when you need it.
Give the VIP a floating IP to publish the service to the internet, and the public address stays put while you add, remove or rebuild the instances behind it.
Key concepts
Load balancer — The front-end object that owns a virtual IP (VIP) on a subnet.
VIP — The virtual IP address clients connect to; it stays stable as members change.
Listener — A protocol and port the load balancer accepts, e.g. HTTPS on 443.
Pool — A group of backend members plus the load-balancing algorithm used to spread traffic.
Member — One backend instance in a pool, given by its address and port.
Health monitor — A periodic check that removes unhealthy members from rotation and restores them when they recover.
L7 policy — A Layer-7 rule that routes or rejects requests based on their content (path, host header, and so on).
Before you start
- A subnet for the VIP that is reachable by your clients.
- For internet exposure, that subnet's network must be connected to a router with an external gateway so a floating IP can reach it.
- Backend instances that are healthy and listening on the port you will balance.
Step by step
- Open Load balancers
Go to Networking and open Load balancers.
Screenshot — The Load balancers list with the Create buttonThe Load balancers list with the Create button - Choose a VIP subnet and plan
- Create a load balancer and select the subnet where its VIP will live.
- Pick a plan sized to your traffic; higher plans support more protocols and throughput.
Screenshot — The Create load balancer form showing the VIP subnet selector and plan optionsThe Create load balancer form showing the VIP subnet selector and plan options - Add a listener
Add a listener for your service, for example HTTPS on 443 or TCP on your application's port.
Screenshot — The listener configuration with protocol and portThe listener configuration with protocol and port - Create a pool and add members
- Create a pool and choose a load-balancing algorithm.
- Add your instances as members, each with its address and port.
Screenshot — The pool form with the algorithm selector and member listThe pool form with the algorithm selector and member list - Attach a health monitor
Add a health monitor so only healthy members receive traffic. For web services an HTTP check against a known path works well.
Screenshot — The health monitor formThe health monitor form - Publish it
Attach a floating IP to the VIP to expose the service to the internet, then point your DNS at that address.
Examples
patrii loadbalancer create --name web-lb --subnet <subnet-id> --plan standard patrii loadbalancer listener create --name web-https \ --loadbalancer <lb-id> --protocol HTTPS --port 443 patrii loadbalancer pool create --name web-pool \ --listener <listener-id> --protocol HTTPS --algorithm ROUND_ROBIN patrii loadbalancer member add <pool-id> --address 10.0.1.11 --port 443 patrii loadbalancer member add <pool-id> --address 10.0.1.12 --port 443 patrii loadbalancer healthmonitor create --pool <pool-id> \ --type HTTPS --delay 5 --timeout 3 --max-retries 3 --url-path /healthz
patrii loadbalancer member add <pool-id> --address 10.0.1.13 --port 443 patrii loadbalancer stats <lb-id>
resource "patrii_lb_loadbalancer" "web" {
name = "web-lb"
vip_subnet_id = patrii_subnet.app.id
}
resource "patrii_lb_listener" "https" {
name = "web-https"
loadbalancer_id = patrii_lb_loadbalancer.web.id
protocol = "HTTPS"
protocol_port = 443
}
resource "patrii_lb_pool" "web" {
name = "web-pool"
listener_id = patrii_lb_listener.https.id
protocol = "HTTPS"
lb_algorithm = "ROUND_ROBIN"
}
resource "patrii_lb_member" "web_1" {
pool_id = patrii_lb_pool.web.id
address = "10.0.1.11"
protocol_port = 443
}
resource "patrii_lb_monitor" "web" {
pool_id = patrii_lb_pool.web.id
type = "HTTPS"
delay = 5
timeout = 3
max_retries = 3
url_path = "/healthz"
}Limits & specifications
Building blocks and common options:
| Part | Options you choose |
|---|---|
Listener protocol | HTTP, HTTPS, TERMINATED_HTTPS, TCP, UDP. |
Pool algorithm | ROUND_ROBIN, LEAST_CONNECTIONS, SOURCE_IP. |
Health monitor | HTTP, HTTPS, TCP, PING, UDP-CONNECT. |
L7 policy | Route to another pool, redirect, or reject based on request content. |
Failover | Trigger a failover to recover the load balancer's data plane. |
Best practices
- Always attach a health monitor; without one, traffic can be sent to a member that has already failed.
- Point health checks at a lightweight endpoint that reflects real readiness, not just that the port is open.
- Use TERMINATED_HTTPS to terminate TLS at the load balancer when you want central certificate handling.
- Choose SOURCE_IP when a client must stick to the same member; otherwise ROUND_ROBIN spreads load evenly.
- Give the VIP a floating IP and put DNS on that, so backend churn never changes your published address.
FAQ
Do I have to create each part separately?
Why is a member marked unhealthy?
What is the difference between HTTPS and TERMINATED_HTTPS?
How do I route different paths to different pools?
Learn more
Everything you can do here in the console is also available through the Patrii Cloud API for automation and scripting.