---
title: "Deploy MySQL HA"
description: "MySQL HA cluster with Group Replication and HAProxy entry point"
category: "Storage"
url: https://railway.com/deploy/mysql-ha
---

# Deploy MySQL HA

MySQL HA cluster with Group Replication and HAProxy entry point

**[Deploy MySQL HA on Railway](https://railway.com/template/mysql-ha)**

- **Creator:** Paulo
- **Category:** Storage
- **Total deploys:** 42

## Template content

### MySQL HA https://upload.wikimedia.org/wikipedia/commons/a/ab/Haproxy-logo.png

- **Image:** ghcr.io/railwayapp-templates/mysql-ha/haproxy:3.2

### MySQL-1 https://devicons.railway.app/i/mysql.svg

- **Image:** ghcr.io/railwayapp-templates/mysql-ha/mysql:8.4

### MySQL-2 https://devicons.railway.app/i/mysql.svg

- **Image:** ghcr.io/railwayapp-templates/mysql-ha/mysql:8.4

### MySQL-3 https://devicons.railway.app/i/mysql.svg

- **Image:** ghcr.io/railwayapp-templates/mysql-ha/mysql:8.4

## Documentation

# MySQL HA

A highly available MySQL cluster using:
- **MySQL Group Replication** (single-primary, consensus built into mysqld)
- **HAProxy** for client connections, routing writes to the current primary

## Architecture

- **MySQL-1 (Primary)**: Current Group Replication primary (may change after failover)
- **MySQL-2+ (Replicas)**: Group members that elect a replacement on primary loss
- **MySQL HA (Edge)**: HAProxy entry point - use this for all client connections

Minimum 3 MySQL nodes: Group Replication is majority-based, so a 2-node group
cannot survive a symmetric partition. 3 members tolerate 1 node loss.

## Connecting

Use the `MYSQL_URL` or `MYSQL_PUBLIC_URL` from the "MySQL HA" (HAProxy) service.
Do not connect directly to individual MySQL nodes.

## Scaling

- **Replicas**: even counts (2/4/6/8) via the cluster overview - the cluster
  totals 3, 5, 7 or 9 members, keeping the voter count odd (Group Replication
  caps membership at 9)


## Similar templates

- [Garage S3 Storage](https://railway.com/deploy/garage-s3-storage) — Ultra-light S3 server: fast, open-source, plug-and-play.
- [Redis](https://railway.com/deploy/redis-1) — Self Host Latest Redis with Railway
- [EasyImg](https://railway.com/deploy/easyimg) — Simple self-hostable Nuxt.js personal image hosting system.

Open this page in a browser: https://railway.com/deploy/mysql-ha
