# Deploy for High Availability

Deploying API7 Gateway for high availability (HA) eliminates single points of failure in both the control plane (CP) and data plane (DP). This guide covers the prerequisites, architecture, and step-by-step instructions for deploying a production-grade HA setup.

For a conceptual overview, see [High Availability](https://docs.api7.ai/api7-gateway/enterprise-features/high-availability.md).

This page explains how to deploy an HA topology. After the deployment is in place, use the configure-and-manage guides for ongoing operations:

* [Scale Data Plane](https://docs.api7.ai/api7-gateway/configure-and-manage/scale-data-plane.md)
* [Autoscale Data Plane on Kubernetes](https://docs.api7.ai/api7-gateway/scalability/autoscale-on-kubernetes.md)
* [Data Plane High Availability](https://docs.api7.ai/api7-gateway/configure-and-manage/high-availability-data-plane.md)
* [Data Plane Resilience](https://docs.api7.ai/api7-gateway/configure-and-manage/data-plane-resilience.md)

Before you deploy, plan the surrounding infrastructure that keeps the cluster available during failures:

* An external PostgreSQL deployment with its own HA or managed failover strategy.
* A load balancer in front of the control plane and another in front of the data plane.
* TLS certificates for the Dashboard and DP Manager endpoints, plus mTLS certificates for data plane nodes.
* A maintenance process that restarts one node at a time and verifies traffic before moving on.

## Architecture Overview[​](#architecture-overview "Direct link to Architecture Overview")

A high-availability deployment consists of:

* **Multiple CP nodes** (Dashboard + DP Manager) sharing a PostgreSQL database, fronted by a load balancer.
* **Multiple DP nodes** in one or more Gateway Groups, fronted by a load balancer.
* **(Optional) A backup gateway node** that periodically exports configuration to external storage (AWS S3 or Azure Blob Storage) for data plane resilience during CP outages.

<!-- -->

## Prerequisites[​](#prerequisites "Direct link to Prerequisites")

### Deployment Checklist[​](#deployment-checklist "Direct link to Deployment Checklist")

Complete the following preparation work before you install or scale any HA nodes:

1. Provision an external PostgreSQL instance or cluster and confirm that automatic failover is handled outside API7 Gateway.
2. Reserve stable DNS names or virtual IPs for the control plane and data plane load balancers.
3. Prepare TLS certificates for the Dashboard and DP Manager endpoints. If data plane nodes connect over mTLS, also prepare the CA and node certificates required by your deployment flow.
4. Confirm that every control plane node uses the same PostgreSQL DSN and that every data plane node connects to the same gateway group through the same DP Manager endpoint.

note

API7 Gateway depends on the availability of PostgreSQL, but it does not configure PostgreSQL replication, promotion, or backups for you. Treat database HA as a prerequisite for control plane HA.

### Minimum Hosts[​](#minimum-hosts "Direct link to Minimum Hosts")

| Component     | Minimum Nodes         | Notes                                                                                                                 |
| ------------- | --------------------- | --------------------------------------------------------------------------------------------------------------------- |
| Control Plane | 2                     | Each runs Dashboard + DP Manager                                                                                      |
| Data Plane    | 2                     | Each runs API7 Gateway                                                                                                |
| PostgreSQL    | Managed or HA cluster | HA configuration is out of scope; see [PostgreSQL HA](https://www.postgresql.org/docs/current/high-availability.html) |

### Hardware Requirements[​](#hardware-requirements "Direct link to Hardware Requirements")

| Component     | CPU     | Memory | Disk  |
| ------------- | ------- | ------ | ----- |
| Control Plane | 4 Cores | 8 GB   | 40 GB |
| Data Plane    | 4 Cores | 8 GB   | 20 GB |

For detailed requirements, see [System Requirements](https://docs.api7.ai/api7-gateway/install/system-requirements.md).

### Network Ports[​](#network-ports "Direct link to Network Ports")

Ensure the following ports are accessible between components:

| Service         | Port        | Protocol     | Description                |
| --------------- | ----------- | ------------ | -------------------------- |
| Dashboard       | 7080 / 7443 | HTTP / HTTPS | Dashboard UI and Admin API |
| DP Manager      | 7900 / 7943 | HTTP / HTTPS | Data plane management      |
| Gateway (HTTP)  | 9080        | HTTP         | API traffic                |
| Gateway (HTTPS) | 9443        | HTTPS        | API traffic                |
| Gateway Status  | 7085        | HTTP         | Health check endpoint      |
| PostgreSQL      | 5432        | TCP          | Database                   |
| Prometheus      | 9090        | HTTP         | Metrics (optional)         |

### Load Balancers and TLS[​](#load-balancers-and-tls "Direct link to Load Balancers and TLS")

For production HA, give each traffic path a stable frontend:

| Endpoint   | Typical frontend                                   | Purpose                                        |
| ---------- | -------------------------------------------------- | ---------------------------------------------- |
| Dashboard  | Ingress, internal load balancer, or reverse proxy  | Operator access to the Dashboard and Admin API |
| DP Manager | Cluster-internal Service or internal load balancer | Stable mTLS address for data plane nodes       |
| Data plane | External load balancer or ingress controller       | Client API traffic                             |

On Kubernetes, the control plane chart already creates separate Services for the Dashboard and DP Manager. A common pattern is to keep `dashboard_service.type: ClusterIP` and expose the Dashboard through an Ingress or internal proxy, while keeping `dp_manager_service` as a stable internal endpoint. If data plane nodes connect from outside the cluster, expose the DP Manager through an internal load balancer or another stable private frontend.

## Control Plane HA[​](#control-plane-ha "Direct link to Control Plane HA")

The API7 Dashboard and DP Manager are stateless applications that store all configuration in PostgreSQL. Deploy multiple instances behind a load balancer for HA.

All control plane replicas must share:

* The same PostgreSQL database.
* The same license state and Dashboard configuration.
* Stable endpoints for operators and data plane nodes.

- Kubernetes (Helm)
- Docker

Scale the control plane by setting replica counts in your Helm values and keeping the service frontends stable:

values.yaml

```
dashboard:

  replicaCount: 2

dp_manager:

  replicaCount: 2



postgresql:

  builtin: false



dashboard_service:

  type: ClusterIP



dp_manager_service:

  type: ClusterIP



dashboard_configuration:

  database:

    dsn: "postgres://api7ee:YOUR_DB_PASSWORD@your-pg-ha-endpoint:5432/api7ee"



dp_manager_configuration:

  database:

    dsn: "postgres://api7ee:YOUR_DB_PASSWORD@your-pg-ha-endpoint:5432/api7ee"
```

❶ Deploy at least 2 Dashboard replicas for redundancy.

❷ Deploy at least 2 DP Manager replicas.

❸ Disable the built-in PostgreSQL and point the control plane to your external HA database.

❹ Keep the Dashboard behind a stable frontend such as an Ingress, internal proxy, or `LoadBalancer` service.

❺ Keep the DP Manager reachable at one stable address for all data plane nodes in the same gateway group.

If Developer Portal remains enabled in the same Helm release, also set `developer_portal_configuration.database.dsn` to the same PostgreSQL endpoint or disable Developer Portal for that release.

Install or upgrade the Helm release:

```
helm upgrade --install api7ee3 api7/api7ee3 --version "~3.10.0" -f values.yaml -n api7 --create-namespace
```

Replace the database password placeholder through your deployment's secret-management workflow; the application does not expand `$DB_PASSWORD` in a literal DSN from the values file.

If you terminate TLS on the Dashboard itself, configure the Dashboard certificate with `dashboard.keyCertSecret`. If you terminate TLS at an Ingress or load balancer instead, keep the backend ports reachable only on the trusted network.

For stronger placement guarantees on Kubernetes, also consider `dashboard.topologySpreadConstraints` and `dp_manager.topologySpreadConstraints` so replicas land on different worker nodes or availability zones.

On each CP host, run both the Dashboard and DP Manager containers.

**Dashboard** (`dashboard-config.yaml`):

dashboard-config.yaml

```
server:

  listen:

    disable: false

    host: "0.0.0.0"

    port: 7080

database:

  dsn: "postgres://api7ee:YOUR_DB_PASSWORD@your-pg-ha-endpoint:5432/api7ee"
```

```
docker run -d --name api7-dashboard \

  -p 7080:7080 \

  --mount type=bind,src="$(pwd)/dashboard-config.yaml",dst=/app/conf/config.yaml,readonly \

  api7/api7-ee-3-integrated:v3.10.7 \

  -c /app/conf/config.yaml
```

**DP Manager** (`dp-manager-config.yaml`):

dp-manager-config.yaml

```
server:

  listen:

    host: "0.0.0.0"

    port: 7900

  advertise:

    host: "DP_MANAGER_HOST_REACHABLE_BY_PEERS"

    port: "7943"

database:

  dsn: "postgres://api7ee:YOUR_DB_PASSWORD@your-pg-ha-endpoint:5432/api7ee"
```

Give each DP Manager host its own configuration file and replace `DP_MANAGER_HOST_REACHABLE_BY_PEERS` with that instance's address. Other DP Manager instances must be able to reach it on the advertised port for diagnostic agent sessions. You can omit `server.advertise` only when peers can reach the container address derived from the accepted connection, such as containers sharing one reachable network.

```
docker run -d --name api7-dp-manager \

  -p 7900:7900 \

  -p 7943:7943 \

  --mount type=bind,src="$(pwd)/dp-manager-config.yaml",dst=/usr/local/api7/conf/conf.yaml,readonly \

  api7/api7-ee-dp-manager:v3.10.7 \

  -c /usr/local/api7/conf/conf.yaml
```

Deploy a supported load balancer in front of the CP hosts to distribute traffic across Dashboard and DP Manager instances.

Configure the load balancer with passive or active health checks and ensure that the backend pool includes every CP node before you point users or data plane nodes to it.

tip

All Dashboard and DP Manager instances must connect to the **same PostgreSQL database**. PostgreSQL HA, whether self-managed or provided by a managed database service, is a separate concern and should be configured according to your database provider's documentation.

## Data Plane HA[​](#data-plane-ha "Direct link to Data Plane HA")

Data plane nodes are stateless — they receive configuration from the control plane and process traffic independently. Deploy multiple nodes behind a load balancer.

For predictable failover behavior, configure the data plane so that:

* Each node belongs to the same gateway group.
* The load balancer only sends traffic to healthy nodes.
* Nodes are distributed across failure domains where possible, such as different hosts, zones, or Kubernetes worker nodes.

### Health Check Configuration[​](#health-check-configuration "Direct link to Health Check Configuration")

Enable the status listener to use these endpoints:

| Endpoint        | Method | Description                                               |
| --------------- | ------ | --------------------------------------------------------- |
| `/status`       | GET    | Returns 200 if the gateway is running                     |
| `/status/ready` | GET    | Checks worker synchronization and DP Manager availability |

When enabled, the status endpoint uses port `7085` in the released chart and examples. It is disabled by default, so enable it before configuring your load balancer to poll it at regular intervals.

Use `/status` for process liveness. Use `/status/ready` when the load balancer should remove a node that loses its DP Manager connection or falls out of sync. To keep nodes with cached configuration in rotation during an outage, check a published traffic port, or a path that still returns success from cached configuration. See [Configure Readiness and Liveness Probes](https://docs.api7.ai/api7-gateway/how-to-guides/ops/configure-readiness-probe.md) for the probe options and [fallback recovery](https://docs.api7.ai/api7-gateway/configure-and-manage/data-plane-resilience.md#recover-traffic-nodes-from-fallback-storage) for nodes that restart.

### Deploy Multiple DP Nodes[​](#deploy-multiple-dp-nodes "Direct link to Deploy Multiple DP Nodes")

* Kubernetes (Helm)
* Docker

Add these HA-oriented settings to the `values.yaml` file you use for the `api7/gateway` chart:

gateway-values.yaml

```
api7ee:

  status_endpoint:

    enabled: true

    ip: 0.0.0.0

    port: 7085



apisix:

  replicaCount: 3



  podDisruptionBudget:

    enabled: true

    minAvailable: 1



  affinity:

    podAntiAffinity:

      preferredDuringSchedulingIgnoredDuringExecution:

        - weight: 100

          podAffinityTerm:

            labelSelector:

              matchExpressions:

                - key: app.kubernetes.io/name

                  operator: In

                  values:

                    - gateway

            topologyKey: kubernetes.io/hostname



gateway:

  readinessProbe:

    httpGet:

      path: /status/ready

      port: 7085

  livenessProbe:

    httpGet:

      path: /status

      port: 7085
```

❶ Expose the status endpoints on port `7085` so Kubernetes and external health checkers can verify node state.

❷ Run at least 2 data plane replicas for HA; start with 3 if you want more headroom during maintenance.

❸ Use a PodDisruptionBudget so voluntary disruptions do not evict all gateway pods at once.

❹ Spread pods across worker nodes to reduce the impact of a single-node failure.

❺ Use separate readiness and liveness checks so the scheduler and load balancers stop sending traffic to nodes that are not ready.

Merge these settings into the Helm script generated by the Dashboard so the mTLS secret and DP Manager connection values remain intact. Include `--version "~3.10.0"` on that Helm command.

Choose the service exposure model that matches your environment. On managed Kubernetes, setting `gateway.type: LoadBalancer` is a common way to provision the data plane frontend. If you already have an ingress controller or external L4/L7 load balancer, keep the service type that fits that design and point the frontend at the gateway Service.

Run gateway containers on multiple hosts. Start with the Docker command generated for the gateway group in the Dashboard because it includes the DP Manager endpoints and mTLS material. If you instead maintain a configuration file, make sure it contains the generated control-plane connection settings and enables the status listener:

gateway-config.yaml (status section)

```
apisix:

  status:

    ip: 0.0.0.0

    port: 7085
```

Mount the complete configuration and expose the status port:

```
docker run -d --name api7-gateway \

  -p 9080:9080 \

  -p 9443:9443 \

  -p 7085:7085 \

  --mount type=bind,src="$(pwd)/gateway-config.yaml",dst=/usr/local/apisix/conf/config.yaml,readonly \

  api7/api7-ee-3-gateway:3.10.7
```

Deploy a load balancer in front of all gateway hosts. Use the health check that matches your traffic policy from [Health Check Configuration](#health-check-configuration) to remove unhealthy nodes from the pool.

For details on health checks and resilience behavior, see [Data Plane High Availability](https://docs.api7.ai/api7-gateway/configure-and-manage/high-availability-data-plane.md).

## Data Plane Resilience (Fallback CP)[​](#data-plane-resilience-fallback-cp "Direct link to Data Plane Resilience (Fallback CP)")

For environments that require the data plane to survive extended control plane outages, configure **Fallback CP**. This feature periodically exports gateway configuration to AWS S3 or Azure Blob Storage. Data plane nodes can then fetch configuration from storage when the control plane is unreachable.

For detailed setup instructions, see [Data Plane Resilience](https://docs.api7.ai/api7-gateway/configure-and-manage/data-plane-resilience.md).

## Verification[​](#verification "Direct link to Verification")

After deploying the HA setup, verify each component:

1. **Control Plane**: Access the Dashboard through the load balancer URL. Confirm that both instances are serving requests by checking access logs on each node.

2. **Data Plane**: Send a test request through the DP load balancer:

   ```
   curl -i "http://<dp-load-balancer>:9080/"
   ```

3. **Health Checks**: Verify the status endpoint on each DP node:

   ```
   curl -i "http://<dp-node>:7085/status"

   # Expected: HTTP/1.1 200 OK
   ```

4. **Failover Test**: Stop one CP node and verify the Dashboard remains accessible through the load balancer. Stop one DP node and verify API traffic continues to flow through the remaining nodes.

## Operational Procedures[​](#operational-procedures "Direct link to Operational Procedures")

Use the following checks during acceptance testing and routine maintenance.

### Control Plane Failover Test[​](#control-plane-failover-test "Direct link to Control Plane Failover Test")

1. Log in to the Dashboard through the control plane load balancer.
2. Stop or isolate one CP node.
3. Refresh the Dashboard and confirm that the session remains usable.
4. Apply a small configuration change, such as updating a route description, and confirm it succeeds.
5. Restore the failed node and confirm it rejoins the load balancer pool.

### Data Plane Failover Test[​](#data-plane-failover-test "Direct link to Data Plane Failover Test")

1. Send repeated requests through the data plane load balancer.
2. Stop or drain one gateway node.
3. Confirm the load balancer health checks mark the node unhealthy.
4. Verify client traffic continues through the remaining gateway nodes without a full outage.
5. Restore the node and confirm it returns to service only after the health check passes.

### Rolling Restart Procedure[​](#rolling-restart-procedure "Direct link to Rolling Restart Procedure")

Perform rolling maintenance one node at a time:

1. Confirm at least one other CP node and one other DP node are healthy before you restart anything.
2. Remove a single node from the load balancer pool or drain it gracefully.
3. Restart that node and wait until it is healthy again.
4. Verify Dashboard access or gateway traffic before moving to the next node.
5. Repeat for the remaining nodes.

Never restart all control plane nodes or all data plane nodes at the same time unless you have planned downtime.

## Next Steps[​](#next-steps "Direct link to Next Steps")

* [Scale Data Plane](https://docs.api7.ai/api7-gateway/configure-and-manage/scale-data-plane.md): Adjust the number of data plane nodes based on traffic.
* [Autoscale Data Plane on Kubernetes](https://docs.api7.ai/api7-gateway/scalability/autoscale-on-kubernetes.md): Use HPA to scale Kubernetes deployments automatically.
* [Data Plane Resilience](https://docs.api7.ai/api7-gateway/configure-and-manage/data-plane-resilience.md): Configure fallback storage for extended CP outages.
* [Production Best Practices](https://docs.api7.ai/api7-gateway/configure-and-manage/production-best-practices.md): Harden your deployment for production workloads.
* [System Requirements](https://docs.api7.ai/api7-gateway/install/system-requirements.md): Review hardware and software requirements.
