> ## Documentation Index
> Fetch the complete documentation index at: https://docs.shardcloud.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Load Balancers

> Distribute requests for your domains across Shard Cloud applications with automatic failover.

A load balancer distributes incoming web requests for your domains across Shard Cloud web apps. The apps that serve those requests are called **targets**. With at least two available targets serving the same route, the load balancer can send traffic to another target when one becomes unavailable.

The Pro plan includes **2 load balancers** and Enterprise includes **10**. Each load balancer supports up to **10 target apps** and **4 domains or subdomains**.

## Set up a load balancer

**1. Prepare your target apps**

Deploy the web apps or APIs that will serve the traffic. Each target needs public web access and a `*.shardweb.app` subdomain. Run the same service on each target that serves a given host.

**2. Create the load balancer**

Open [Load balancers](https://shardcloud.app/dash/load-balancers) in the dashboard, click **Create load balancer**, and give it a name.

**3. Add applications**

Click **Add application** and choose each target. Use **Main route** for a shared pool, or create a named route for a specific service.

**4. Connect a host**

Click **Connect host**, choose the route, and attach your domain or subdomain. For a domain with DNS managed by Shard Cloud, the dashboard can create the required records. For external DNS, copy the records shown in the dashboard to your DNS provider. A hostname can be attached to one application or load balancer at a time.

**5. Verify traffic**

Wait for the host's DNS status to become active, then open the HTTPS URL and verify that the service responds.

## Route domains to specific apps

A host on **Main route** can send traffic to every enabled target on the load balancer. Assign a host and its target apps to the same named route to limit which apps receive the host's traffic. For example, put `api.example.com` and your API replicas on an `API` route, and `www.example.com` and your frontend replicas on a `Frontend` route.

## Maintain your targets

For a rolling release, pause one target, deploy and verify it at its own app URL, then enable it before updating the next target. Keep an enabled target for each host. While a host is connected, the load balancer requires at least one enabled target. Changes such as pausing a target or removing a host can take a few minutes to reach all traffic.

Keep shared data such as sessions, uploads, and application state in a shared database or storage service when requests may land on different apps.

## Load balancer settings

* **Response timeout** controls how long the load balancer waits for a target before trying another. The default is **10 seconds**. The dashboard accepts **1–30 seconds**.
* **Custom error page** lets you upload HTML to show when no target on a route can respond.

Deleting a load balancer removes its routing configuration and detaches its hostnames. The target apps remain available through their own URLs.

See the [CLI commands](https://docs.shardcloud.app/cli/commands.md#lb) for managing load balancers and their targets from a terminal.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.