Deploy Valkey 9 Open-Source Redis Alternative

BSD-licensed, Redis-compatible store with JSON, Bloom and Search modules.

Deploy Valkey 9 Open-Source Redis Alternative

Just deployed

Just deployed

Bucket

Bucket

Just deployed

Deploy and Host Valkey with Railway

Deploy on Railway

Valkey is an open-source (BSD-3-Clause) key-value store that continues the Redis 7.2 code base under the Linux Foundation. This community template runs Valkey 9.1 with the JSON, Bloom and Search modules, AOF + RDB persistence on a volume, daily backups to a Railway Bucket, and the same variables as Railway's Redis.

About Hosting Valkey

Valkey speaks the Redis protocol, so existing Redis clients and apps connect without code changes. Running it well on a platform still takes some care: the password must be on from the first boot, memory must be capped below the service limit so the server refuses writes instead of being killed, data must survive redeploys, and you need copies off the volume. This template handles that. It generates the password, sizes maxmemory from the container's memory limit at every start, writes an append-only file every second plus RDB snapshots, listens on IPv4 and IPv6 for Railway's private network, and runs a nightly cron job that streams a verified snapshot to a Bucket. It has no web UI, which keeps it lean.

Common Use Cases

  • A drop-in, BSD-licensed replacement for Redis behind caches, sessions, rate limiters, pub/sub and streams
  • Job queues and background workers that use a Redis-protocol broker
  • JSON documents with JSONPath reads and partial updates (JSON.SET, JSON.GET)
  • Vector, full-text, tag and numeric search over hashes or JSON (FT.CREATE, FT.SEARCH, FT.AGGREGATE), e.g. for RAG or semantic caching
  • Deduplication and "seen before?" checks with Bloom filters (BF.ADD, BF.EXISTS)

Dependencies for Valkey Hosting

  • Valkey 9.1 with modules (included: valkey/valkey-bundle 9.1.4 = Valkey 9.1.3, valkey-json 1.0.3, valkey-bloom 1.0.1, valkey-search 1.2.1)
  • A Railway volume at /data (included)
  • A Railway Bucket for backups (included, created by the template)

Deployment Dependencies

Implementation Details

ServiceSourcePurpose
Valkeybuilt from this repo (services/valkey, FROM valkey/valkey-bundle:9.1.4-trixie)Valkey 9.1.3 + JSON, Bloom, Search; volume at /data; private port 6379 (IPv4 + IPv6); TCP proxy for external clients
Valkey Backupsame image, VALKEY_SERVICE_ROLE=backupCron job, daily 03:30 UTC: snapshot, check, upload, 14-day retention (newest 3 runs always kept)
BucketRailway BucketPrivate S3 storage for the snapshots

Switching from Railway's Redis: the Valkey service exposes the same variables (REDIS_URL, REDIS_PUBLIC_URL, REDISHOST, REDISPORT, REDISUSER, REDISPASSWORD, REDIS_PASSWORD) plus VALKEY_URL and VALKEY_PUBLIC_URL. In your app, change the reference from ${{Redis.REDIS_URL}} to ${{Valkey.REDIS_URL}} and redeploy. Caches and queues refill on their own. To keep existing data, copy it at the command level (read each key, write it again); RDB and DUMP payloads from Redis 7.4 and later use a newer format that Valkey loads only on a best-effort basis.

First steps

  1. Copy REDIS_PUBLIC_URL from the Valkey service and connect from your machine: valkey-cli -u "{REDIS_PUBLIC_URL}" or redis-cli -u "{REDIS_PUBLIC_URL}". RedisInsight and other Redis GUIs connect with the same URL (user default).
  2. PING answers PONG; INFO server shows valkey_version:9.1.3; MODULE LIST shows json, bf and search.
  3. Try the modules: JSON.SET user:1 $ '{"name":"Ada"}', BF.ADD seen:emails ada@example.com, FT.CREATE idx ON HASH PREFIX 1 doc: SCHEMA title TEXT tag TAG.
  4. From other Railway services, use ${{Valkey.REDIS_URL}} (private network, no egress cost).

Memory and persistence: at every start the deploy log prints one summary line with the values in use. maxmemory is 75% of the service's memory limit (VALKEY_MAXMEMORY takes a percentage, a size such as 2gb, or 0 for no cap). The policy is noeviction, which is safe for queues and sessions: writes fail when memory is full. For a pure cache set VALKEY_MAXMEMORY_POLICY=allkeys-lru or allkeys-lfu. The append-only file is fsynced every second (VALKEY_APPENDFSYNC), and RDB snapshots run on Valkey's default schedule (VALKEY_SAVE, off for AOF only). Settings come from variables at every start; CONFIG SET changes last until the next restart. Add other server options with VALKEY_EXTRA_FLAGS, e.g. --notify-keyspace-events Ex.

Backups and restore: each run writes valkey/{UTC time}/dump.rdb and, last, MANIFEST.txt (size, SHA-256, key count, versions) to the Bucket. The snapshot is taken over Valkey's replication protocol, checked with valkey-check-rdb, and nothing on the volume is touched. Run one now with railway cron run --service "Valkey Backup". To restore:

  1. Pick a run folder that contains MANIFEST.txt (Bucket files, or railway ssh --service Valkey -- valkey-railway list).
  2. On the Valkey service, set VALKEY_RESTORE_FROM={run folder}, e.g. 20261031T033000Z, and deploy.
  3. The log shows the download, the SHA-256 and structure checks, and the AOF being rebuilt from the snapshot. The previous data is moved to /data/pre-restore-{time}, not deleted.
  4. Clear VALKEY_RESTORE_FROM afterwards. The same run is never restored twice on one volume. Writes made after the backup's time are not in the restored data.

Security: the 32-letter password is required on every connection, including the TCP proxy; the server refuses to start without one. DEBUG, MODULE LOAD and changes to protected settings are disabled (Valkey defaults). The TCP proxy carries Redis protocol without TLS, like Railway's Redis: delete it in Settings → Networking if only Railway services connect.

Scaling: Valkey runs as one primary. Raise the service's memory and CPU limits; maxmemory and the Search module's thread pools follow at the next start. For very high throughput on 4+ vCPU, set VALKEY_IO_THREADS to 2–8. The AOF and RDB files need roughly one to two times the dataset on disk: Hobby volumes are 5 GB, Pro volumes start at 50 GB and can be resized. Replicas, Sentinel and cluster mode are not part of this template.

Versions and upgrades: the image is pinned in services/valkey/Dockerfile (tag and digest). To upgrade, change the valkey/valkey-bundle tag, take a backup, and redeploy; Valkey reads data files written by older versions but not newer ones, so plan downgrades from a backup. The deploy log shows the running version.

Cost: about $1 per month idle and about $6 per month for a few hundred MB of data with daily backups, at Railway's usage prices.

Why Deploy Valkey on Railway?

Railway runs Valkey, its backup job and the Bucket together on a private network with a persistent volume, so you get a password-protected, persistent, Redis-compatible store with off-volume backups in a few minutes. Apps switch over by changing one reference, and the server grows by raising the service limits.


Template Content

More templates in this category

View Template
RustFS | (Just Updated) S3 Object Store, Public URL and Keys Set
S3-compatible object store, keys and public URL preset, volume kept

SuperSlowSloth
0
View Template
TimescaleDB
A PostgreSQL-based time-series database for analytics on Railway.

Rakit
1
View Template
Garage S3 Storage
Ultra-light S3 server: fast, open-source, plug-and-play.

PROJETOS
8