- At least two (2) origin servers to configure traffic with.
If you haven't got any servers to configure yet, or are looking to test things out, our friends at Digital Ocean have a fantastic tutorial on setting up nginx on Ubuntu 16.04 that you can follow (twice over!).
Click "Create a Load Balancer" and provide the hostname for your Load Balancer—the DNS name the Load Balancer will be available at.
- If you have an existing DNS record at this name, your Load Balancer will supersede it once you deploy it (more details).
- The "orange cloud" to the right of the hostname indicates that Cloudflare will proxy the traffic, allowing you to benefit from the same caching, security and performance benefits that you would normally benefit from. If you want a DNS-only Load Balancer (e.g. for a non-HTTP(S) protocol) you can click this to set it to "grey cloud" (unproxied) mode (read more on how that works).
Note: If needed, we could add custom headers, change the timeout & retries, and check for a specific response body. If our origin responded without that body, we'd mark it as unhealthy.
Right now we have no pools associated with this Load Balancer, so let's create our two Pools: the primary pool, and our secondary "backup" pool that will serve traffic if our primary pool fails.
Click "Create new Origin Pool" -
We'll name our pool (this must be unique) and add our origin server address. We're adding an IP address here, but if our origin server had a hostname (e.g. someapp.googleapps.com), we could enter that instead.
The "Health Threshold" defines how many origin servers must still be healthy before the Pool itself is marked unhealthy. We only have 1 origin server here, so we'll leave this at 1. The Monitor will default to the one we selected in the first step, but we could override that here. We'll also enter the email address that we want status (healthy vs. unhealthy) notifications to be sent to; this could also be a mailing list address (e.g. a Google Group) or a PagerDuty address
if we wanted to share these with a larger team.
Click "Save" when you're done.
We'll also add a second Pool, similar to our first:
After creating each pool, the health will be "unknown" for a moment while we fire off our health checks.
The dashboard will poll for updated health status every 60 seconds, and you should see a green "healthy" status or a red "critical" status if the health check failed. If you're seeing failures, you can mouse-over the tooltip and see the exact reason it failed. Failure reasons, and steps to resolve, can be found here in our knowledge-base
Note: If you're on a Free, Pro or Business plan, you can add up to 10 Pools.
Note: If we had existing pools, we could also add them to this Load Balancer by selecting them in the drop-down and clicking "Add Pool".
Once you're done with Pool creation, click "Next"
By default, pools are ordered by when we created them. You can re-order them by dragging the number to the left.
If you also have Geo Routing enabled as part of your subscription, you can configure specific traffic policies and failover ordering by geographic region
- e.g. directing all European traffic to your eu-datacenter Pool, and then failing over to north-america Pool, with the inverse for North America. This can be extremely useful when you want visitors to access the closest origin server to them (and improve performance as a result!).
Once you're happy with the configuration and have reviewed it, click "Save and Deploy" to immediately deploy it to production.
It will then show up in your dashboard and start load balancing traffic.
You can drill-down into the Pools and origin servers that make up the Load Balancer to check for individual status and/or disable specific Pools or origin servers (e.g. for planned maintenance).
Note: Disabling a Pool will disable it for all Load Balancers it is a member of, so take caution in disabling a Pool when you have multiple Load Balancers.
You can also share your Load Balancer with other sites in your account by creating a CNAME record - e.g. you can CNAME "www.example.com" to "lb.moonbrookbowlsclub.com" in the DNS app
. This is useful if you want to share the same configuration with multiple other domains, and saves you having to re-create the Load Balancer each time.
You can also configure separate Load Balancers for each domain, and re-use the same Monitors and Pools. This can be useful if you want to change the failover order for different domains - e.g. perhaps "example.co.uk" has a different failover priority from "example.com" or "example.com.au".
You can also refer to the Load Balancing knowledge-base articles for more tips and configuration advice.