Deploy Redis HA (w/ Cluster Mode, Sharded 3+3)
One‑click Redis Cluster (3 nodes + 3 replicas) with automatic failover
Redis A
Just deployed
/data
Redis B
Just deployed
/data
Redis F
Just deployed
/data
Redis E
Just deployed
/data
Initiator
Just deployed
Redis D
Just deployed
/data
Redis C
Just deployed
/data
Deploy and Host Redis HA (w/ Cluster Mode, Sharded 3+3) on Railway
Redis Cluster HA (Sharded 3+3) deploys a six‑node Redis Cluster: three masters sharding the 16,384 hash slots, each with a dedicated replica for high availability. It delivers horizontal write scaling, automatic failover, and slot‑based routing. Clients connect with a cluster‑aware driver (e.g., ioredis Cluster) over Railway’s private network or through the exposed TCP proxies on each node.
About Hosting Redis HA (w/ Cluster Mode, Sharded 3+3)
This template provisions six Redis services in cluster mode (3 masters + 3 replicas) and a one‑shot init job that forms the cluster and exits once healthy (can be deleted after reaching the "Completed" status). Masters split all 16,384 slots; replicas continuously sync and are auto‑promoted if a master fails (majority of masters required). All nodes advertise internal hostnames and run on Railway’s private network for reliable cluster‑bus communication. Connect using a cluster‑aware client like ioredis Cluster class.
Common Use Cases
- Horizontally scalable, highly available cache/session store
- High‑throughput job/queue/stream workloads (use hash tags to co‑locate multi‑key ops)
- Read scaling via replicas for analytics and dashboards (optional read‑from‑replica)
Dependencies for Redis HA (w/ Cluster Mode, Sharded 3+3) Hosting
- A cluster‑aware client library (e.g., ioredis Cluster, Jedis/Lettuce Cluster, go‑redis v9)
- One shared Redis password across all nodes (injected via variables referenced from Redis Node A)
Deployment Dependencies
- Redis Cluster (OSS) docs: https://redis.io/docs/latest/operate/oss_and_stack/management/scaling/
- ioredis Cluster usage: https://github.com/luin/ioredis#cluster
Implementation Details
Client (Node + ioredis inside Railway):
import Redis from "ioredis";
import dns from "dns";
const seeds = [
{ host: process.env.REDIS_A_HOST, port: 6379 },
{ host: process.env.REDIS_B_HOST, port: 6379 },
{ host: process.env.REDIS_C_HOST, port: 6379 },
// (Optional) include replicas too
// { host: process.env.REDIS_D_HOST, port: 6379 },
// { host: process.env.REDIS_E_HOST, port: 6379 },
// { host: process.env.REDIS_F_HOST, port: 6379 },
];
const cluster = new Redis.Cluster(seeds, {
// Resolve both IPv4/IPv6
dnsLookup: (hostname, cb) => dns.lookup(hostname, { family: 0 }, cb),
redisOptions: { password: process.env.REDIS_PASSWORD }, // This is the Redis Node A password
// Optional: read from replicas ("master" | "replica" | "all")
scaleReads: "master",
});
// Use it as normal
await cluster.set("foo", "bar");
const value = await cluster.get("foo");
console.log(value);
await cluster.quit();
Quick verify commands:
redis-cli -h masterhostnamehere -a passwordhere cluster inforedis-cli -h masterhostnamehere -a passwordhere cluster nodes
Notes:
- The template forms a 3‑shard cluster with one replica per shard. Failover promotes a replica if a master fails (requires a majority of masters).
- Multi‑key commands must target keys in the same hash slot; use hash tags like user:{123}:profile.
Why Deploy Redis HA (w/ Cluster Mode, Sharded 3+3) on Railway?
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying Redis HA (w/ Cluster Mode, Sharded 3+3) on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
Template Content
Redis A
redis:8.4.0Redis B
redis:8.4.0Redis F
redis:8.4.0Redis E
redis:8.4.0Initiator
redis:8.4.0Redis D
redis:8.4.0Redis C
redis:8.4.0