Sharding: Architecture Pattern

Scalability stands as a crucial tenet that underpins the design and development of systems, applications, and infrastructure. Scaling is a default in today’s world of distributed systems and while we can scale our services easily(assuming they’re stateless!), the same cannot be said for our stateful systems like data-stores. In this article, we’ll delve into one of the common ways to horizontally scale Stateful systems!

Sharding

Sharding is a technique used to horizontally partition a data-store into smaller, more manageable fragments called shards, which are distributed across multiple servers or nodes. This allows us to scale our data-stores not only in terms of storage, but also in terms of compute as the queries and operations on each node are only for a subset of the data i.e shard.

Sharding Techniques

The choice of sharding approach depends on factors such as the nature of the data, access patterns, scalability requirements, and the specific characteristics of the system. Here are some common sharding techniques:

  1. Range-Based Sharding: Range-based sharding involves partitioning data based on a specific range of values within a chosen attribute. For example, data can be partitioned based on the range of customer IDs or timestamps. This approach allows for efficient querying of contiguous ranges of data but may lead to data skew if the distribution of values is uneven.
  2. Hash-Based Sharding: Hash-based sharding…

--

--

Pratik Pandey - https://pratikpandey.substack.com

Senior Engineer with experience in designing and architecting large scale distributed systems.