vado / docs
GitHub

How it works

Sharding and routing

Keys hash to 16,384 slots, slots map to shards in contiguous ranges, and a database's size and placement are fixed when it is created.

Where two keys landCRC16 mod 16,384, the same function the router runs
0123456789101112131415

First key: slot 8000, shard 7. Second key: slot 8000, shard 7. Each shard owns 1,024 contiguous slots.
Same slot: any multi-key command, transaction or script over both keys works.

A key with a non-empty {hashtag} hashes only the part in braces, so related keys can share a slot.

Slots and shards

A key hashes to one of 16,384 slots with CRC16, as in Valkey Cluster, and a {hashtag} hashes only the part in braces. Shard i of n owns a contiguous range of slots, so a shard could later split without remapping its neighbours. A 1-shard database has no cross-slot limits.

Shard count

A database is created on first use with the shard count of the SHARD_EPOCHS entry in force at that moment, or with an explicit count through the bench API (/db?db=<name>&shards=<n>).

SHARD_EPOCHS, ordered by from, the first at 0
[
  { "from": 0, "shards": 1 },
  { "from": 1800000000000, "shards": 16 }
]

Append an epoch to size new databases. Never edit an existing one: its databases would route to the wrong shards.

Placement

With a regions list (regions=weur,enam, or regions=world for all nine), shard i is created with the location hint regions[i % n]. Without one, shards go to LOCATION_HINT if set, or near their first caller. The pub/sub shard always uses LOCATION_HINT.

A hint applies when an object is created; an existing shard keeps its place. Durable Objects hinted to sam, afr or me run in a nearby region instead. The dashboard shows where each shard actually runs.

How the router routes

CommandWhere it goes
Keys in one slotThat shard, unchanged and pipelined, or a nearby replica for reads
MGET, MSET, DEL, UNLINK, EXISTS, TOUCHSplit by shard, replies merged in key order
SCAN, KEYS, DBSIZE, FLUSHALL, INFOEvery shard, 32 at a time, after every earlier reply
SCRIPT LOAD, FUNCTION LOADEvery shard, so EVALSHA and FCALL work wherever their keys land
SUBSCRIBE, PUBLISHThe database's pub/sub shard
AUTH, HELLO, SELECT, CLIENT, WAIT, WAITAOF, CONFIGAnswered by the router itself

CROSSSLOT

Other multi-key commands with keys in different slots get CROSSSLOT, and so do MULTI, WATCH and Lua over keys in different slots. Put related keys under one {hashtag}, or use a 1-shard database. A transaction always runs on its shard's socket.

The commands the router answers itself are refused inside MULTI: queued, they would reach one shard's connection instead of the router.

Shard classes

Objects of one Durable Object class on one machine can share a process, and with it the memory limit and the single thread. Objects of different classes never do. So the shard is exported as eight classes, and shard i uses class i % 8: a database's shards 0 to 7 never share a process.

Replicas of class k live in class 8 + k, so a replica never shares a process with a primary. In tests, 16 shards in one class ran in 14 processes, one holding 3 shards; with 8 classes they ran in 16.

Connections

Each router opens a socket to every shard and replica it uses, which keeps per-shard order for free. Past 128 sockets in one Worker process (ROUTER_SOCKET_BUDGET), new upstreams send batches of commands as method calls instead, which cost more per batch: 200 connections over 16 shards measured about 20 to 26k ops/s.

Shard sockets idle for 30 s close, so an idle shard stops being billed and can sleep. The client's connection doesn't notice.

Unsupported commands

MONITOR; SYNC, PSYNC, REPLICAOF and FAILOVER (replication is internal); SHUTDOWN, DEBUG, MIGRATE, MOVE, SWAPDB, SAVE, BGSAVE, BGREWRITEAOF and ACL; CLIENT TRACKING and the other connection-wide CLIENT subcommands; SELECT above 0 (use another database name); CONFIG inside MULTI.

Browse topics or type to search

Introductionvado runs real Valkey 9.1, compiled to WebAssembly, in Cloudflare Durable Objects. A router in a Worker spreads keys over the shards, so valkey-cli and ioredis see one ordinary server.What you getIntroductionA first commandIntroductionThe dashboardIntroductionRead onIntroductionQuick startCreate the Access application, deploy the Worker, and connect valkey-cli or ioredis. About ten minutes on Workers Paid.1. Create the Access applicationQuick start2. DeployQuick start3. Connect valkey-cliQuick start4. Connect from a WorkerQuick startRun it locallyQuick startArchitectureA router per connection, shard objects running Valkey with their AOF in SQLite, and memory-only replicas in other regions. What each part owns, and what it costs.Where everything livesArchitectureHow clients reach itArchitectureRouterArchitectureShardsArchitectureRead replicasArchitectureRewritersArchitectureCatalogArchitectureWatcher, Pulse and the dashboardArchitectureWhat the design buys, and costsArchitectureSharding and routingKeys hash to 16,384 slots, slots map to shards in contiguous ranges, and a database's size and placement are fixed when it is created.Slots and shardsSharding and routingShard countSharding and routingPlacementSharding and routingHow the router routesSharding and routingCROSSSLOTSharding and routingShard classesSharding and routingConnectionsSharding and routingUnsupported commandsSharding and routingDurabilityEvery acknowledged write is in SQLite before its reply leaves. Group commit keeps that cheap under load, a helper object compacts the AOF, and deploys restart shards without failing commands.Write-through storageDurabilityGroup commitDurabilityAOF rewrites in a helperDurabilityWhen a shard resetsDurabilityClean restarts on deployDurabilityRead replicasEach shard can keep a memory-only copy in other regions, fed from its AOF. Routers read the nearest one, a connection always reads its own writes, and an idle database's replicas sleep.RegionsRead replicasCopy, then streamRead replicasWhat a replica read can seeRead replicasFailuresRead replicasIdle sleepRead replicasLife of a requestWhat happens between a client sending SET k v and reading +OK, and what each reply tells you.One SET, step by stepLife of a requestWhat a reply tells youLife of a requestOperationsDeploy, configure, create databases with a placement, sign in to the dashboard, drive the bench API, and upgrade without breaking running shards.DeployOperationsSettingsOperationsCreate a database with a placementOperationsDashboard sign-inOperationsThe bench APIOperationsUpgrading safelyOperationsSecurityWho can connect, what clients may change, how data travels, where copies live, and what the bench token and the dashboard allow.AuthenticationSecurityWithout a passwordSecurityWhat clients can changeSecurityTransportSecurityReplicas and data locationSecurityThe bench token and the dashboardSecurityLimits and measurementsWhat one shard holds, how fast writes and reads went, and the conditions behind each number. Measured on production in November 2026, on one account.LimitsLimits and measurementsMemoryLimits and measurementsThroughputLimits and measurementsLatencyLimits and measurementsReplicasLimits and measurementsRewritesLimits and measurementsCold starts and deploysLimits and measurementsFailure testsLimits and measurementsWhat these don't showLimits and measurementsRedisA database can run Redis 8.12 instead of Valkey. It is opt-in at build time because it doubles the upload and is distributed under the AGPLv3.Choosing RedisRedisBuilding with RedisRedisDifferencesRedisThe AGPL licenceRedisRepositoryAn npm workspace: two apps and three packages. How to check, test and build it, and what CI runs on every push.LayoutRepositoryCommandsRepositoryEnd-to-end testsRepositoryContinuous integrationRepositoryThe wasm buildsRepositoryCode rulesRepository
Local search. Nothing is sent to a server.Esc to close
Documentation