Sharded

Several writers, each owning one storage shard, and a reader group per shard. Ingest scales with writers, queries with readers.

How it works

Each writer holds the Lease on one storage shard. A span routes to a shard by a hash of its namespace and trace ID, under the routing epoch in effect at the trace's earliest span, and any writer accepts any span and forwards each trace to the shard's owner. Each shard gets its own reader group, and a query fans out to every group and merges the results. Adding writers schedules a new epoch: new shards take data from the next aligned hour, and old data never moves.

Deploy

A shared bucket is required: grant S3 access first. Hover a field to see what it does:

traces.yaml
1apiVersion: telemetry.plural.sh/v1alpha12kind: Traces3metadata:41  name: traces52  namespace: telemetry6spec:73  mode: Sharded84  config:95    retention: 14d10    storage:116      path: traces12      objectStore:137        type: Aws14        aws:158          region: us-east-1169          bucket: acme-telemetry17    write:1810      durability: applied1911      flushIntervalSeconds: 1020    sharding:2112      leaseDurationSeconds: 152213    segmentDurationSeconds: 360023    request:2414      maxCandidates: 100002515      maxSpansPerTrace: 10000026  writer:2716    replicas: 32817    resources:29      requests: { cpu: "1", memory: 2Gi }30      limits: { memory: 4Gi }3118    cacheVolume:32      persistentVolumeClaim:33        accessModes: [ReadWriteOnce]34        resources: { requests: { storage: 20Gi } }35  reader:3619    replicas: 23720    cacheVolume:38      emptyDir: { sizeLimit: 20Gi }3921  ingress:40    enabled: true41    hostname: traces.acme.internal42    ingressClass: nginx
  1. 1name
    Also names the ServiceAccount the IAM role binds to, and the traces-writer and traces-reader Services (just traces in Standalone mode).
  2. 2namespace
    The Kubernetes namespace the pods run in. Tenant namespaces for your data are separate and come from NamespaceAuthentication resources.
  3. 3mode
    Standalone (the default) runs one pod that reads and writes. Sharded runs a writer StatefulSet and one reader StatefulSet per storage shard, which scale independently.
  4. 4config
    Rendered into the server's config file. The operator rolls the pods when it changes.
  5. 5retention
    How long data is kept, counted from ingestion, as 14d, 2w or 36h. Default 14d.
  6. 6path
    Object-key prefix inside the bucket; shard suffixes are appended. Must match the prefix in the IAM policy. Default traces.
  7. 7type
    Aws, Gcp, Azure, Local or InMemory. With Aws and no key references, the pod uses its Pod Identity credentials.
  8. 8region
    Bucket region. Add endpoint (and allowHTTP if needed) for S3-compatible stores such as MinIO.
  9. 9bucket
    Can be shared by all three databases, as long as their path prefixes differ.
  10. 10durability
    When a write is acknowledged: applied (default) once in memory, written once in SlateDB's mutable state, durable once uploaded to object storage.
  11. 11flushIntervalSeconds
    How often writers flush to object storage, and so how far readers can lag behind. Default 10.
  12. 12leaseDurationSeconds
    How long a shard Lease survives without renewal before another writer may take the shard over. Default 15; renewIntervalSeconds (default 5) must be lower.
  13. 13segmentDurationSeconds
    Width of a time partition. Searches prune whole segments by time. Default 3600.
  14. 14maxCandidates
    Most traces one TraceQL search will decode and evaluate. Default 10000.
  15. 15maxSpansPerTrace
    Safety limit while assembling a trace by ID. Default 100000.
  16. 16replicas
    Writer count, which is also the storage shard count. Raise it at any time; new shards take writes from the next aligned hour. It cannot be lowered.
  17. 17resources
    Defaults to 250m CPU and 512Mi memory requests with a 2Gi limit. Budget for the write buffer: 64 MiB per shard, plus up to two frozen buffers being flushed.
  18. 18cacheVolume
    Mounted at /var/cache/traces as the disk tier of the block cache (512 MiB RAM and 10 GiB disk by default). A PVC keeps it warm across restarts. Set exactly one of emptyDir or persistentVolumeClaim.
  19. 19replicas
    Replicas per reader group. Each storage shard gets its own group, which opens only that shard; any reader answers any query by asking the other groups over gRPC. Default 2 in Sharded mode. Scale freely, or set autoscaling to scale each group on CPU.
  20. 20cacheVolume
    An emptyDir is enough: a restarted reader refills its cache from the bucket.
  21. 21ingress
    Optional. One hostname that routes /write to the writers and /read to the readers. Add tls and pathPrefix as needed.

Apply it with kubectl apply -f traces.yaml, then add credentials and connect your tools. The operator rolls the pods whenever the spec changes.

bash
kubectl -n telemetry get traces
# NAME   MODE      READY   AGE
# traces Sharded   True    2m

kubectl -n telemetry port-forward svc/traces-reader 3200 &
curl -u grafana:"$PASSWORD" http://localhost:3200/read/ns/payments/api/v2/search/tags

Scaling

  • Writers: raise spec.writer.replicas. See scaling for how many writers your peak rate needs and how to size each one. New pods start first, and the new shards take traces from the next aligned hour, by each trace's earliest span. Scale-down is blocked.
  • Readers: spec.reader.replicas sets the replicas per reader group. Change it at any time, or set spec.reader.autoscaling to scale each group on CPU. New groups appear as writers add shards. See reader groups.
  • Large traces: raise request.maxSpansPerTrace and reader memory together.