Zettel — MessageBus Routing, BucketId Prefix Splitting, and Ideal State Convergence
Vespa’s elastic content layer (vespa/storage/src/vespa/storage/distributor/) partitions documents across variable-depth 64-bit BucketId prefixes and maps each bucket deterministically to a ranked preference list of storage nodes using the cluster state version published by vespa/clustercontroller-core.
Mechanism & Upstream Grounding
- Document-to-Bucket Hashing (
vespa/document/src/vespa/document/bucket/):- Every
DocumentId(id:<namespace>:<doctype>:<key-value>:<user-specific>) is hashed into a 58-bit location + 6-bit prefix-length count (BucketId). Co-located user/group keys share high-order location bits so group-scoped queries and visits hit a single bucket subtree.
- Every
- Stateless Rendezvous / Ideal-State Placement (
vespa/storage/src/vespa/storage/common/content_bucket_space.cpp):- Given the current
ClusterState(node capacities, up/down/maintenance states, and hierarchical distribution groups), the Ideal State algorithm hashes(BucketId, node_index)to select the owningdistributorand the ordered replica list (redundancycopies,searchable-copiesready inproton).
- Given the current
- Dynamic Split/Join & Background Merge (
vespa/storage/src/vespa/storage/distributor/operations/idealstate/):- When a bucket exceeds
bucket-split-sizeorbucket-split-count, the distributor increments its used-bit count (splitting one prefix into two child buckets); when sibling buckets shrink below half the threshold, they are joined.
- When a bucket exceeds
Boundary Conditions & Trade-offs
- Zero Central Metadata Bottleneck: Neither clients nor
messagebushops consult a central bucket directory table; any node with the compactClusterStatestring computes bucket ownership locally in microseconds (see feeding-operations).