Valkey 9 Open-Source Redis Alternative
Valkey is an open-source (BSD-3-Clause) key-value store that continues the Redis 7.2 code base. This template runs Valkey 9.1 with the JSON, Bloom and Search modules, persistence on a volume, daily backups to a Railway Bucket, and the same variables as Railway's Redis.
What you get
- Valkey 9.1.3 with the JSON, Bloom and Search modules
- Generated password required on every connection
- Append-only file and RDB snapshots on a volume at /data
- Daily backup job to a Railway Bucket with 14-day retention
- Redis-style variables such as REDIS_URL for easy switching
Good for
- A BSD-licensed replacement for Redis behind caches, sessions and queues
- JSON documents with JSONPath reads and partial updates
- Vector and full-text search for RAG or semantic caching
- Bloom-filter checks for deduplication
Services in this template
- Valkey · from
baranberkay96/valkey-railway - Valkey Backup · from
baranberkay96/valkey-railway
Questions people ask
How do I connect?
Copy REDIS_PUBLIC_URL from the Valkey service and use it with valkey-cli or redis-cli. From other Railway services use the REDIS_URL reference on the private network.
How do I switch from Railway's Redis?
The Valkey service exposes the same variables. In your app, change the reference from the Redis service to the Valkey service and redeploy. Existing data must be copied at the command level.
What happens when memory is full?
maxmemory is set to 75% of the service's memory limit with the noeviction policy, so writes fail instead of the server being killed. For a pure cache, set VALKEY_MAXMEMORY_POLICY to allkeys-lru or allkeys-lfu.
How do backups and restores work?
The backup job writes a checked snapshot and a manifest to the Bucket daily. To restore, set VALKEY_RESTORE_FROM to a run folder and deploy. The previous data is moved to a pre-restore folder, not deleted.
What is not included?
One primary only. Replicas, Sentinel and cluster mode are not part of this template. The TCP proxy carries the Redis protocol without TLS; delete it if only Railway services connect.
Full template README
Deploy and Host Valkey with 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-bundle9.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
- Valkey documentation: https://valkey.io/docs/
- Valkey source: https://github.com/valkey-io/valkey
- valkey-bundle image: https://github.com/valkey-io/valkey-bundle
- Modules: https://github.com/valkey-io/valkey-json, https://github.com/valkey-io/valkey-bloom, https://github.com/valkey-io/valkey-search
- Railway Storage Buckets: https://docs.railway.com/storage-buckets
- Railway cron jobs: https://docs.railway.com/cron-jobs
Implementation Details
| Service | Source | Purpose |
|---|---|---|
| Valkey | built 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 Backup | same image, VALKEY_SERVICE_ROLE=backup |
Cron job, daily 03:30 UTC: snapshot, check, upload, 14-day retention (newest 3 runs always kept) |
| Bucket | Railway Bucket | Private 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
- Copy
REDIS_PUBLIC_URLfrom the Valkey service and connect from your machine:valkey-cli -u "{REDIS_PUBLIC_URL}"orredis-cli -u "{REDIS_PUBLIC_URL}". RedisInsight and other Redis GUIs connect with the same URL (userdefault). PINGanswersPONG;INFO servershowsvalkey_version:9.1.3;MODULE LISTshowsjson,bfandsearch.- 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. - 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:
- Pick a run folder that contains
MANIFEST.txt(Bucket files, orrailway ssh --service Valkey -- valkey-railway list). - On the Valkey service, set
VALKEY_RESTORE_FROM={run folder}, e.g.20261031T033000Z, and deploy. - 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. - Clear
VALKEY_RESTORE_FROMafterwards. 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.
Guides for this template
View Valkey 9 Open-Source Redis Alternative on railway.com
Similar templates
| Template | Category | DeploymentsDeploys |
|---|---|---|
| PostgreSQL PostgreSQL database service | Storage | 394,257 |
| MySQL Deploy a MySQL database service | Storage | 269,034 |
| MongoDB MongoDB database service | Storage | 40,707 |
| Redis Deploy and Host Redis with Railway | Storage | 25,288 |
| Redis (Bitnami) Redis key-value data store | Storage | 15,087 |
| pgvector Open-source vector similarity search for Postgres | Storage | 2,077 |