How Horizontal Sharding Boosts Database Performance with Hash Routing
Horizontal sharding splits a large table into multiple databases using hash‑modulo routing, improving performance and scalability; the article explains the basic algorithm, shows example calculations for a 4‑shard setup, and demonstrates how to expand shards from four to eight.
Horizontal sharding splits the contents of a large table into different tables to improve database performance. 1 table → N tables.
Sharding is decided by a routing algorithm. Common routing algorithms: hash value modulo.
For example, divide the database into 4 shards.
Set the modulo value to 1024 .
Thus each shard occupies 256 positions. Compute the shard for the value test1234:
hash(test1234) = 3109729401 % 1024 = 537How to expand shards? For example, to expand from 4 shards to 8, split each original shard into 2, so each shard occupies 128 positions.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java High-Performance Architecture
Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
