Project OWNOpen Web Node
GitHub

04Hosting

Load balancers

A load balancer puts one address in front of several servers, so they share the visitors and keep the site up when one stops. In Project OWN (Open Web Node) it's a kind of site, built with a guide that tests every server first and then proves the result works.

What it does

  • One domain, with HTTPS, in front of up to 16 servers, called backends: your other servers, other Project OWN servers, or apps on this one.
  • Each visitor goes to the least busy backend. Under light traffic the first one does most of the work; under load they share it.
  • A backend that stops answering is skipped, and tried again after 10 seconds.
  • There are no sticky sessions: one visitor's requests can go to different backends.

Before you start

  • Every backend should serve the same site. The builder warns when they serve different pages.
  • Logins: apps that keep logins on each server (session cookies such as PHPSESSID or laravel_session) sign people out behind a balancer, unless the backends share sessions and uploads. The builder warns when it sees one.
  • Private networks are best. HTTPS to a backend keeps the traffic private on the way, but the backend's certificate isn't checked. Put backends on a private network, or connect the servers with Tailscale.

Build one

Open Sites, click Add a site, type the domain visitors will use, and choose Load balancer. The builder takes over, in four steps.

  1. Where should visitors go? Enter each backend as address:port, such as 10.0.0.5:80 for plain HTTP, or https://app2.example.com:443. Click + Add another backend for more, then Test them and continue.
  2. How should it check they're well? Enter the Health check page: any page every backend serves quickly, such as / or /health. A page that needs a login won't do. Click Test and continue.
  3. Which address will visitors use? Check the domain, and tick Also answer on the www. version if you want it. Click Continue.
  4. Build it, and prove it works. Check the summary and click Build and prove it.

When a backend doesn't answer

Each backend is tested from this server as you add it. One that answers shows Ready, with its answer and how long it took. One that doesn't shows Not answering, says why in plain words, and adds What to do:. The usual reasons:

  • nothing is listening on that port;
  • a firewall drops the connection;
  • the name doesn't resolve;
  • HTTP and HTTPS are mixed up;
  • the page is missing or forbidden.

You go on only when every backend answers. Fix it and press the button again, or remove that backend.

The proof

After building the balancer, Project OWN proves it works:

  1. It asks each backend again.
  2. It sends 30 visits through the balancer.
  3. It takes each backend out in turn (up to four) to show the others carry the site, then puts them all back.

The result says "DOMAIN works", or "DOMAIN needs a fix" with each step marked OK or Fix this and what to do. Click Done.

Then point the domain at this server and get a free certificate on the site's page, like any site.

Afterwards

  • The site's page has a Load balancer card that shows each backend and how it's answering.
  • Change backends lets you add or remove backends and change the health check page, then Save.
  • Check it works runs the proof again, any time.
  • Every backend is asked for the health check page every two minutes. Doctor says when one stops answering, with what to do.
  • A balancer has no files of its own, so it isn't backed up. It comes back from the recovery kit on its settings alone.

From the API

RouteWhat it does
POST /api/balancers/probeTests backends
POST /api/sites with "kind": "balancer"Adds a balancer
GET, PUT /api/sites/{id}/balancerShows or changes its backends
POST /api/sites/{id}/balancer/checkRuns the proof

See API and AI assistants for tokens.

Something wrong or unclear on this page? Open an issue on GitHub.