Spread traffic with a load balancer
A load balancer sits in front of your cloud servers and shares visitors between them. If one server stops answering, the load balancer stops sending it traffic until it recovers. Load balancers run in Toronto, next to your servers.
Point your domain at it
Under Address, the panel shows the load balancer's IP address and name. Add a DNS record for your domain:
- For
www.example.ca, add a CNAME record pointing to the load balancer's name. - For a bare domain such as
example.ca, add an A record pointing to its IP address.
Add forwarding rules
A rule says which port the load balancer listens on and where it sends that traffic on your servers.
- Under Forwarding rules, choose Add a rule.
- Pick the Protocol: HTTP, HTTPS or TCP.
- Set the Server port. HTTPS goes to port 80 on your servers unless you choose another.
- Choose Add rule.
Turn on Sticky sessions for a rule when a visitor must stay on one server, for example when your app keeps logins in server memory.
Choose the servers
Under Servers, tick the servers that should take traffic, then choose Save servers. Open the rule's port to the load balancer in each server's firewall.
Set the health check
The Health check decides whether a server can take traffic. Enter a Path, like /health, to request it over HTTP, or leave it empty to check only that the port accepts a connection. Choose Save health check.
Serve HTTPS
An HTTPS rule needs a certificate for your domain. We issue it from Let's Encrypt and renew it for you.
- Under HTTPS certificate, enter the Domain.
- Add both records the panel lists under Records for your domain. The second one lets us renew the certificate, so keep it in place.
- Add an HTTPS rule. The Status changes to issued once we've checked the records.
Your domain's DNS can stay with your current provider.
If something goes wrong
- Visitors get an error page. No server passes the health check. Check the path and port, and that the firewall lets the load balancer in.
- The certificate stays "Not issued yet". One of the two DNS records is missing or hasn't spread yet. DNS changes usually show within an hour; allow up to 24.
Still stuck? Ask us and we'll walk you through it.