---
title: "Load balancers"
description: "A public IPv4 address, an IPv6 address or both in front of your VPC's instances, with TCP, TLS, HTTP and HTTPS listeners, target groups and health checks."
---

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

# Load balancers

A load balancer is a public IPv4 address, an IPv6 address or both in front of a VPC's instances. A
**listener** takes connections on a port, over TCP or TLS, and sends them to a **target group**; an HTTP or
HTTPS listener routes each request by its host, path and more. A target group's
**targets** are private network interfaces or private addresses in the VPC. Connections go to healthy targets. If
every target in a group is unhealthy, they go to all of them.

- [Target groups](/load-balancers/target-groups) — Targets, health checks, PROXY protocol and deregistration.
- [TLS listeners](/load-balancers/tls) — End TLS at a load balancer with an EZGH certificate.
- [Route HTTP traffic](/load-balancers/http) — HTTP and HTTPS listeners: rules by host and path, redirects, weighted forwarding.
- [Firewalls](/load-balancers/firewalls) — Admit a load balancer to your targets.
- [IPv6](/load-balancers/ipv6) — Dual stack, IPv6 only, and allowed sources for each family.

The Load Balancers API is at `https://lb-api.ezghcloud.com`. In the console, open **Load balancers**.

## Before you start

A load balancer needs:

- a [subnet](/private-networks/vpcs) with an attached [Network Gateway](/private-networks/network-gateways)
  and an active route for each family it answers on (`0.0.0.0/0` for IPv4, `::/0` for IPv6), and at
  least **16 free addresses**. Load balancers use addresses in their subnet, and targets see
  connections from them;
- for IPv4, an allocated [public IPv4 address](/compute/ipv4-addresses) that isn't associated with
  anything. Without one, a load balancer answers on [IPv6](/load-balancers/ipv6) only.

Targets can be in any subnet of the VPC.

## Create a load balancer

1. Create a target group, and register its targets:

   ```sh
   ezgh lb target-groups create web --vpc vpc_5p7r9s3t1vxz --port 8080
   ezgh lb targets register tgp_7t3n1v8c2wzd --network-interface eni_7hq2m0x9ka3c
   ```

2. Create the load balancer. This takes minutes, and `--wait` waits until it's active:

   ```sh
   ezgh lb load-balancers create storefront \
     --subnet sbn_2m9x0a7qpe4k --ipv4-address pip_9d3f1h6j2lnr --wait
   ```

3. Add a listener:

   ```sh
   ezgh lb listeners create lbr_4k2m9x0a7qpe \
     --protocol tcp --port 80 --target-group tgp_7t3n1v8c2wzd
   ```

4. [Admit the load balancer](/load-balancers/firewalls) on your targets' firewalls, then check that
   they're healthy:

   ```sh
   ezgh lb targets list tgp_7t3n1v8c2wzd
   ```

In the API, [CreateLoadBalancer](/lb-api/CreateLoadBalancer/) answers `202` with an operation.
The load balancer exists from then on, `provisioning`, with its ID.

The load balancer also answers on IPv6 when its subnet has a `::/0` route; `--no-ipv6` keeps it
IPv4 only. See [IPv6](/load-balancers/ipv6).

## Status

| Status | Means |
| --- | --- |
| `provisioning` | It's being created. |
| `active` | It's serving its listeners. |
| `deleting` | It's being deleted. |
| `deleted` | It's gone. |

`lastChange` says how your latest change is going: `applying`, `applied` or `not_applied`, with a
`reason`. A change that wasn't applied leaves the load balancer serving as it was, and the console
shows why on its page.

## Listeners

A listener has a protocol (`tcp` or `tls`), a port, a target group and:

- **Allowed sources** (`allowedSourceCidrs`): the IPv4 and IPv6 CIDRs that may connect, at most 20,
  everyone (`0.0.0.0/0` and `::/0`) unless you say otherwise. Each family admits only the clients its
  own ranges cover: a list with no IPv6 range admits no IPv6 client. Other clients' connections get no
  answer. The list can't be empty, and a CIDR can't have bits set past its mask.
- **Idle timeout**: how long a connection may sit idle, 60 to 6000 seconds, 350 by default.

A listener's protocol doesn't change: add another. Moving a listener to another target group leaves
open connections where they are, and new ones go to the new group.

## Delete a load balancer

```sh
ezgh lb load-balancers delete lbr_4k2m9x0a7qpe --wait
```

Its listeners go with it. Its target groups stay, unused, and its public IPv4 address stays allocated
in the project. A [firewall rule](/load-balancers/firewalls) naming it stops the delete with
`409 load_balancer_referenced`: delete the rule first.

## Pricing

A load balancer's capacity scales automatically. Its price follows its capacity tier, charged by
the hour:

| Capacity tier | Price |
| --- | --- |
| 1 | $7 per month |
| 2 | $20 per month |
| 3 | $50 per month |

Every load balancer starts at tier 1. A month is 730 hours. Its public IPv4 address is billed as an
[IPv4 address](/compute/ipv4-addresses#pricing).

## Limits

| Limit | Value |
| --- | --- |
| Load balancers per project | 2 by default, up to 20 |
| Target groups per project | 10 by default, up to 100 |
| Listeners per load balancer | 10, one per port |
| Targets per target group | 500 |
| Allowed sources per listener | 20 |

## IAM

| Policy | Allows |
| --- | --- |
| `LbFullAccess` | Everything here. |
| `LbReadOnlyAccess` | Listing and viewing load balancers, target groups and targets. `ReadOnlyAccess` includes the same. |

Some actions also need access to what they name:

| Action | Also needs |
| --- | --- |
| Create a load balancer | `network.subnets.get` on its subnet, `network.publicIps.associate` on its address |
| Add a listener, or move one to another target group | `lb.targetGroups.update` on the target group |
| Use a certificate on a listener | `certificates.certificates.use` on it |
| Register a network interface | `network.networkInterfaces.get` on it |

Source: https://docs.ezghcloud.com/load-balancers/index.mdx
