- At least two (2) origin servers for which to configure traffic
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).
Here you can also enable Session Affinity. For further detail on this feature, please see Load Balancing: Session Affinity.
Click Next to continue.
Next, we'll create and add a Pool. We are going to create two Pools: the primary pool, and our secondary "backup" pool that will serve traffic if our primary pool fails.
Click Create an origin pool and then we'll name our Pool (this must be unique) and name 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. If you had previously configured Pools, you can select and add those here instead. Click Save to continue.
By default, pools are ordered by date created. You can re-order them by dragging the number to the left. For now, we will leave the order as is and click Next to continue.
Note: If necessary, we could add custom headers, change the timeout and retries, and check for a specific response body. If our origin responded without that body, we'd mark it as unhealthy.
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. You can select specific regions from which we would send Health Checks as well. 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 repeat these steps to add the Health Check to the secondary pool.
After attaching a Health Check, the status will be unknown for a moment while we fire off our first 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
Now click Next to continue.
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!).
Again, click Next to move on to the final step.
Your last step is to review your Load Balancing configuration and decide whether you need to make any changes. From here you can edit any of the configuration. Once you are satisfied, you can either Save as Draft to save your work but not use the load balancer yet, or Save and Deploy to immediately start load balancing that hostname.
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.