How it works
Sharding splits an index across machines, and it is worth doing only when one machine cannot hold the index or replicas cannot absorb the reads. If the whole index is 8 GB, replicas of one full copy may be all you need. Otherwise, a prefix range map can assign terms to serving shards. Equal alphabet ranges are often unbalanced: common initial letters and one-letter prefixes may be much hotter than rare ones. Measure bytes, request rate, and CPU per range, then split busy ranges or add read replicas. Version the routing map during movement.
As an example, three shards cover a–i, j–r, and s–z, with s–z receiving 45% of 5,600 reads per second. That is 2,520 per second. If a node handles 1,000, s–z needs three replicas, while the other two shards at 1,540 each need two. If memory is fine, replicas fix this without touching the ranges.
If a requested prefix spans shards, the query tier must fetch candidates from each relevant shard and merge their top-K results, much as Elasticsearch merges results across its shards. The request is then as slow as the slowest shard. Keeping all descendants together avoids this fanout but can concentrate storage and traffic. Precomputing lists for very short prefixes in a small separate table also avoids fanout where it would be broadest. A merged response should not combine incompatible ranking versions.
The “s” shard is saturated while “x” is quiet. Name two remedies.
Replicate the hot “s” slice to spread reads or split its range and merge candidates for affected prefixes. Measure storage and fanout tradeoffs.
Use this as a guide for self review; written answers are not graded.Keep in mind
- Partition boundaries should reflect measured load, not equal letter counts.
- Cross-shard prefixes need fanout and merge; replicas address read heat.