Epoch sharding
SlateDB allows one writer per database. Plural Telemetry gets many writers by routing each record to a storage shard, using a hash of its identity and the routing epoch in effect at its timestamp.
Waiting for the first traced record…
Press Scale writers to schedule a new epoch, and watch the cutover land on the next hour. Send late record emits an entry with an old timestamp: it routes by the epoch that was in effect then, into a shard that already holds that time range. Switch to Read path to watch a 90-minute range query fan out across every shard, including the ones a scale-up added mid-range, and merge back on the reader.
Routing
Every product hashes a canonical key with the first 128 bits of BLAKE3:
| Product | Routing key | Routed by |
|---|---|---|
| Metrics | namespace + canonical labels | each sample's timestamp. A series straddling a cutover is split into one write per epoch |
| Logs | namespace + canonical stream labels | each entry's timestamp |
| Traces | namespace + trace ID | the trace's earliest span start |
The hash selects a range in the epoch's hash-range map. Ranges are aligned to 4,096 routing slots (the high 12 bits), which caps a deployment at 4,096 storage shards. The slot is only a routing granularity and is never stored in keys.
record ─► (namespace + labels | trace ID, timestamp)
─► epoch = last epoch with effective_from <= timestamp
─► shard = epoch.range_for(blake3_128(key))
─► owner of shard (Lease holder)
├── this writer ──────────────► SlateDB put
└── another writer ─► gRPC ──► SlateDB put (retry on stale owner)Stale ownership responses refresh the assignment and are retried up to write.remoteRetries times. Forwarding fan-out is bounded by write.remoteConcurrency.
Routing epochs
A ShardMap holds an ordered, append-only list of epochs, each with an effective_from_ns timestamp and a shard count. Because epochs only grow, every shard referenced by an older epoch still exists and stays readable.
Scaling writers from 2 to 4:
- The operator sees the new
writer.replicasand creates podswriter-2andwriter-3. - The Lease-elected coordinator appends epoch 1 to the
ShardMapusing aresourceVersioncompare-and-swap. The epoch is effective at the next aligned boundary that's at least the lead time away: one-hour alignment and two minutes of lead by default. - Writers and readers watch the
ShardMap, apply only increasing generations, and acquire Leases for their assigned shards. - At the cutover, new records route by epoch 1. Shards 2 and 3 start as new, empty SlateDB databases. No data is copied, cloned or drained.
Repeated scale requests before a cutover replace the pending epoch instead of stacking epochs. The coordinator then rebalances ownership across the StatefulSet, which moves Leases but not data.
Reads
The reader that receives a query coordinates it over every storage shard [0, shard_count) and merges:
- Metrics deduplicates series by fingerprint across shards.
- Logs merges streams with equal labels.
- Traces merges partial traces from every shard a trace ID may have been routed to.
Reader groups
Readers are partitioned into one group per storage shard, and each group's replicas open only that shard. Any reader still answers any query: it reads its own shard in process, and asks each other shard's group over the internal ShardReader gRPC service.
Grafana ─► reader-1 (any group)
├── shard 1 ─► in process, never over gRPC
├── shard 0 ─► gRPC stream ─► reader-0 group
└── shard 2 ─► gRPC stream ─► reader-2 group
merge ─► Prometheus / Loki / Tempo JSONShard responses are compact protobuf streams: Metrics sends chunk-encoded samples for the coordinator's PromQL engine, Logs sends each shard's partial LogQL output, and Traces sends matching traces and TraceQL hits. Only the coordinating reader converts the merged result to the public API's JSON. A shard-scoped call is never forwarded again, so a query makes at most one hop per remote shard.
Each group sits behind a headless Service. A reader spreads calls across the group's replicas, fails over when one is down, and hedges to a second replica if the first hasn't answered within 250 ms. A query fails rather than returning partial results when a group has no reachable replica.
| Without groups | With groups |
|---|---|
| Every reader opens every shard | Each reader opens one shard |
| Reader memory and cache working set grow with shard count | Per-pod footprint stays one shard's worth |
| Readers scale only as whole-dataset copies | Each group scales on its own, with a per-group HPA |
| No query traffic between readers | Remote shards' partial results cross the network |
Per-shard limits apply per shard: Logs maxPages and Traces maxCandidateTraces bound each shard's work. A trace can only be split across shards when its spans run across a cutover that moves its ID. Hits within an hour of such a cutover are fetched and re-evaluated whole; every other hit is used as its shard returned it. A structural TraceQL query can still miss a split trace when no single shard's part matches it.
The operator runs one reader StatefulSet per shard and adds groups as writers scale up. Set spec.reader.readGroups.enabled: false to return to readers that each open every shard. See cost estimates for what groups change in your bill.
Why Kubernetes
| Primitive | Used for |
|---|---|
| StatefulSet | Stable writer identities (writer-0, writer-1, …) across restarts and scaling |
ShardMap CR | The single versioned source of truth for epochs and assignments |
Lease | Exclusive ownership of each physical shard, plus coordinator election |
Kubernetes already gives you a CP datastore with watches and compare-and-swap. Using it means Plural Telemetry needs no ZooKeeper, etcd or gossip ring of its own, and adds no new dependency to clusters that already run it.
Tuning
- Keep
sharding.renewIntervalSecondswell belowsharding.leaseDurationSeconds(defaults 5 and 15). sharding.ioConcurrencyLimitis a per-pod storage I/O budget, independent of shard count. The operator infers 96 permits per GiB of requested memory (minimum 128) unless you set it explicitly.- Every forwarding participant must share the internal auth token when
auth.internalTokenSecretRefis set.