---
title: "Deploy KeyDB | (Just Updated) Redis Alternative, Threads Sized To Your vCPUs"
description: "KeyDB Redis alternative. Password on, threads sized to vCPUs, data kept"
category: "Storage"
url: https://railway.com/deploy/keydb-or-just-updated-redis-alternative-
---

# Deploy KeyDB | (Just Updated) Redis Alternative, Threads Sized To Your vCPUs

KeyDB Redis alternative. Password on, threads sized to vCPUs, data kept

**[Deploy KeyDB | (Just Updated) Redis Alternative, Threads Sized To Your vCPUs on Railway](https://railway.com/template/keydb-or-just-updated-redis-alternative-)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/keydb-or-just-updated-redis-alternative-/manifest.json

- **Creator:** SuperSlowSloth
- **Category:** Storage

## Template content

### keydb

- **Image:** eqalpha/keydb:latest@sha256:6537505c42355ca1f571276bddf83f5b750f760f07b2a185a676481791e388ac
- **Start command:** `/bin/sh -c 'set -e; M=$(cat /sys/fs/cgroup/memory.max 2>/dev/null || echo max); Q=$(cut -d" " -f1 /sys/fs/cgroup/cpu.max 2>/dev/null || echo max); if [ "$M" != max ]; then MM=$((M / 100 * 70)); else MM=0; fi; if [ "$Q" != max ]; then CORES=$(( (Q + 99999) / 100000 )); else CORES=$(nproc); fi; T=$CORES; [ "$T" -gt 4 ] && T=4; echo "[railway] cores=$CORES server-threads=$T maxmemory=$MM appendonly=everysec owner=$(stat -c %u:%g /data)"; exec keydb-server /etc/keydb/keydb.conf --always-show-logo no --port 6379 --bind 0.0.0.0 :: --requirepass "$KEYDB_PASSWORD" --dir /data --appendonly yes --appendfsync everysec --server-threads "$T" --maxmemory "$MM" --maxmemory-policy noeviction'`

## Documentation

# Deploy and Host KeyDB on Railway

KeyDB is a multi-threaded, Redis-compatible in-memory datastore. It speaks the Redis protocol, so
existing clients, queues, rate limiters and caches connect to it unchanged, while serving them from
several threads instead of one.

This template runs KeyDB 6.3 as a single service from a digest-pinned official image: the Redis port
on a Railway TCP proxy, and a Railway volume holding an append-only file and snapshots.

## About Hosting KeyDB

- **Threads follow your plan.** KeyDB defaults to a handful of threads regardless of the container.
  The start command reads the container's CPU quota and starts that many server threads, capped at
  four, and prints the number it chose in the deploy log.
- **Memory is capped below the limit.** `maxmemory` is set to 70% of the container's memory limit with
  `noeviction`, so a full instance returns errors instead of being killed by the platform.
- **Writes survive restarts.** Append-only persistence (`everysec`) is on, with the data on the
  Railway volume at `/data`; a redeploy or a crash loses at most about a second of writes.
- **A password is required from the first connection.** It is generated per deploy; anonymous clients
  are rejected.
- **Two ways in.** Services in the same project use the private URL; clients elsewhere use the TCP
  proxy URL. Both IPv4 and IPv6 are listened on, so the private network works.

## Common Use Cases

- A drop-in replacement for Redis as a cache or session store
- Job queues (BullMQ, Sidekiq, Celery) and rate limiters on the Redis protocol
- Leaderboards, counters and real-time state shared between services
- Workloads that outgrow a single-threaded Redis on one container

## Dependencies for KeyDB Hosting

- One Railway volume for the append-only file and snapshots (created by the template)

### Deployment Dependencies

- KeyDB documentation: https://docs.keydb.dev
- Official image: https://hub.docker.com/r/eqalpha/keydb

### Implementation Details

| Variable | Purpose |
| --- | --- |
| `KEYDB_PASSWORD` | Password for connections, generated per deploy. |
| `KEYDB_URL` | `redis://` URL on the private network, for services in the same project. |
| `KEYDB_PUBLIC_URL` | `redis://` URL on the TCP proxy, for clients outside Railway. |

Python:

```python
import redis
r = redis.from_url("")
r.set("hello", "world")
```

## Why Deploy KeyDB 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 KeyDB 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.


## Similar templates

- [TimescaleDB](https://railway.com/deploy/timescaledb-railway-template) — A PostgreSQL-based time-series database for analytics on Railway.
- [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

Open this page in a browser: https://railway.com/deploy/keydb-or-just-updated-redis-alternative-
