Skip to content

How-to

Health monitors

A health monitor checks each member of a load balancer pool on a schedule. The load balancer stops sending traffic to a member that fails its checks, and sends traffic to it again once it passes.

Each pool has at most one health monitor. Without one, the load balancer keeps sending traffic to a member even when its application has stopped.

Before you start

  • A load balancer with a listener, a pool and members: see HTTP and TCP load balancers.
  • Something on each member for the monitor to check. For an HTTP monitor, a path that returns 200 while the application is healthy, such as /health, served by nginx or Apache on Linux or IIS on Windows.
  • The members' security group allows the pool's port from the subnet the members are on. The checks come from the load balancer on that subnet, not from the internet.

Choose a type and settings

Type Passes when Use with
HTTP A request to the URL path returns one of the expected codes HTTP pools
HTTPS The same, over TLS Pools whose members serve HTTPS
TCP The member accepts a connection on the pool's port Any TCP pool, when there's no URL to check
Setting What it does
Delay Seconds between checks
Timeout Seconds to wait for an answer. Keep it shorter than the delay
Max retries Checks in a row that must pass before a failed member gets traffic again
Max retries down Checks in a row that must fail before a member stops getting traffic. Defaults to 3
URL path, expected codes For HTTP and HTTPS: the path to request, and the codes that count as healthy. Defaults to / and 200

A member stops getting traffic once max retries down checks in a row have failed. With a delay of 5 seconds and the default of 3, that takes under a minute. Shorter delays find failures sooner, and send more checks to every member.

Add a health monitor

The Breqwatr Cloud Portal (Strata) doesn't create health monitors. Use the CLI or OpenTofu.

Find the pool, then add the monitor to it:

openstack --os-cloud <cloud-name> loadbalancer pool list -c name -c protocol
openstack --os-cloud <cloud-name> loadbalancer healthmonitor create \
  --name web-health --type HTTP --url-path /health --expected-codes 200 \
  --delay 5 --timeout 3 --max-retries 2 --wait web-pool

For a TCP monitor, leave out --url-path and --expected-codes.

Add the monitor next to the pool it checks:

resource "openstack_lb_monitor_v2" "web" {
  name           = "web-health"
  pool_id        = openstack_lb_pool_v2.web.id
  type           = "HTTP"
  url_path       = "/health"
  expected_codes = "200"
  delay          = 5
  timeout        = 3
  max_retries    = 2
}
tofu plan
tofu apply

Check it worked

Each member's operating status shows what the monitor found:

openstack --os-cloud <cloud-name> loadbalancer member list web-pool -c address -c protocol_port -c operating_status
  • ONLINE: the member passes its checks and gets traffic.
  • ERROR: the member is failing its checks and gets no traffic.
  • NO_MONITOR: the pool has no health monitor.

To see it work, stop the application on one member: sudo systemctl stop nginx on Linux, or Stop-Service W3SVC in PowerShell on Windows. After a few checks, that member shows ERROR and requests to the load balancer still succeed. Start it again, and it returns to ONLINE.

Change or remove a health monitor

openstack --os-cloud <cloud-name> loadbalancer healthmonitor set --delay 10 --timeout 5 web-health
openstack --os-cloud <cloud-name> loadbalancer healthmonitor delete web-health

Change the settings in the resource and apply. Remove the resource and apply to delete the monitor.

The pool keeps its members when the monitor is deleted, and every member goes back to NO_MONITOR.