A router that does not run your SQL.
For each statement the gateway finds the route key, works out which shard owns it, and relays the client's bytes to a session on that shard. It does not parse whole statements or decode rows, so it adds tens of microseconds, not milliseconds.
Sharding and the gateway shipped in 1.1.0: every release server can run as a shard, and the gateway has release archives of its own. Not built yet: backup and restore of a whole cluster at one point, commit timestamps from a hybrid logical clock, and splitting a shard by cloning it.
The gateway routes; the shards guard
New in 1.1.0: a gateway sends each statement to the shard that owns its key. A shard refuses rows outside its ranges, so a stale map costs a retry and never a wrong answer.
- 1A keyed statement
UPDATE orders SET status = 'paid' WHERE store_id = 7 AND id = 912 arrives at the gateway over any protocol.
- 2Find the route key
The gateway reads store_id = 7 from a cached route template. It does not run the SQL.
- 3Look up the map
The signed shard map, at epoch 41, says the range holding store 7 lives on shard 2.
- 4Relay to shard 2
The client's bytes go to a session on shard 2 over multiplexed, mutually authenticated rastcp.
- 5A stale map is refused
If the range moved, shard 2 refuses with RDB02 and a newer epoch; the gateway fetches the map and retries on shard 3.
- 6Without a key: fan out
SELECT count(*) goes to every shard, and the gateway merges the answers.
What it speaks
- PostgreSQL, MySQL and SQL Server clients on the front
- rastcp to the shards: multiplexed, mutual TLS, optional zstd frames
- SCRAM-SHA-256 with channel binding, checked at the gateway
- A thread-per-core design: each client stays on one worker
Measured on a development build
A prepared point read by key, one client, a three-shard cluster and the gateway on one machine, profiling build. Directly to a shard it took 42-50 µs; through the gateway, 63-66 µs. The gateway spends about 17 µs of CPU per statement, two thirds of it in the kernel: two reads, two writes and two waits, the floor for any TCP proxy. Representative of the gateway's own cost, not of a multi-host cluster.
Built to be operated
- Zero-downtime upgrades: the new process binds beside the old with SO_REUSEPORT, the old drains
- Prometheus /metrics and SHOW GATEWAY
- Route-template caches per core and shared
- Limits that fail loudly: sessions, in-flight requests, message and gather sizes
rasterizeddb_gateway --map cluster.map --listen 0.0.0.0:6432 --auth scram