NEW RasterizedDB 1.1.0 is out: sharding and the gateway, the message broker, roles and row-level security, compression, .NET on NuGet, and the enterprise edition. What's new ›
SHARDING NEW IN 1.1.0

From one machine to many, by key.

A gateway that speaks the protocols your apps already use sends each statement to the shard that owns its key. Shards are ordinary RasterizedDB servers, and every one refuses a row outside the key ranges it owns, so a stale map costs a retry, never a wrong answer.

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.

HOW IT WORKS · ANIMATED 12 s cycle

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.

CLIENTPostgreSQL, MySQLor SQL Server GATEWAY UPDATE orders … WHERE store_id = 7 route key: store_id = 7 map epoch 41 → shard 2 refused → map epoch 42 → shard 3 fan-out: merge count from 3 shards does not run the SQL SHARD 1SHARD 2SHARD 3 relayed over mux rastcp, mTLS SHARD 2RDB02 · range movedrefused before any effect ✓ retried on shard 3 count(*) → 41,208
  1. 1
    A keyed statement

    UPDATE orders SET status = 'paid' WHERE store_id = 7 AND id = 912 arrives at the gateway over any protocol.

  2. 2
    Find the route key

    The gateway reads store_id = 7 from a cached route template. It does not run the SQL.

  3. 3
    Look up the map

    The signed shard map, at epoch 41, says the range holding store 7 lives on shard 2.

  4. 4
    Relay to shard 2

    The client's bytes go to a session on shard 2 over multiplexed, mutually authenticated rastcp.

  5. 5
    A 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.

  6. 6
    Without a key: fan out

    SELECT count(*) goes to every shard, and the gateway merges the answers.

1 / 3

Two ways to shard

Key sharding spreads one table's rows across shards by a route key, a customer or a store id, with fan-out for statements that span them. Per-user shards place each login on one shard at authentication and keep the session there, for isolation rather than scale.

  • Key sharding: hash of a route key, a signed shard map with epochs
  • Per-user shards: login role → one shard, no fan-out, no override
  • Reference tables copied to every shard for local joins
  • Two-phase commit for writes that span shards
2 / 3

Correctness does not depend on the gateway

The gateway routes; the shards guard. A read or write for a key range a shard does not own is refused there, so a gateway with an old map or a wrong template produces a retry or an error and never rows from the wrong place.

3 / 3

In your ORM too

The Rust client routes by itself when you would rather not run a gateway: declare the shard key on the model, and every query that carries it goes straight to its shard.

Rust
#[derive(Model)]
#[rdb(table = "orders", partition_by = "store_id, id", shard_by = "store_id")]
struct Order { store_id: i64, id: i64, total: Decimal }
✓ page rendered in 249 µs axum + tera + htmx · no other javascript