Skip to content

Failover

Let’s say we have two web servers, www1 and www2. They are both supposed to host www.example.com. www1 is the primary server; as long as it is up, it should be the one to serve traffic. But if it goes down, traffic should be shifted over to www2, the secondary.

layers: {
up: {
www1: www1.example.com\n192.0.2.1
www2: www2.example.com\n198.51.100.1
user -> Greenlight: ?\nwww.example.com
user <- Greenlight: 192.0.2.1
Greenlight -> www1: HTTPS GET /ready
Greenlight <- www1: ✅
Greenlight -> www2: HTTPS GET /ready
Greenlight <- www2: ✅
}
down: {
www1: www1.example.com\n192.0.2.1
www2: www2.example.com\n198.51.100.1
user -> Greenlight: ?\nwww.example.com
user <- Greenlight: 198.51.100.1
Greenlight -> www1: HTTPS GET /ready
Greenlight <- www1: ❌
Greenlight -> www2: HTTPS GET /ready
Greenlight <- www2: ✅
}
}
  1. Create a Plain Resource Record
  2. Add two pool members, one for www1 and another for www2. Use a Conditional Function Kind
    • For the “Condition”, choose a TCP Connection Check or an HTTP Check. Configure it to perform a suitable health check against your server. In the above example, the HTTP Checks would have the URLs https://www1.example.com and https://www2.example.com
    • For the “If True” and “If False” parts of the Conditional, choose a Constant Function Kind
      • “If True” is 192.0.2.1, the primary’s address
      • “If False” is 198.51.100.1, the secondary’s address1
  1. If you want more than two servers in your failover chain (i.e. more than just a primary and a secondary), you can replace the “If False” constant with another Conditional. That Conditional can then health check the secondary server and fail over to a tertiary server. And so on… ↩