Skip to main content

Sharding is the practice of logically dividing or partitioning data, usually using a specific key (referred to as a shard key), and then placing that data on separate hosts (subsequently known as shards). This is generally done to scale horizontally (more hosts) as opposed to vertically (more powerful hosts) and can provide significant cost benefits, particularly with the now ubiquitous availability of cloud computing.

Sharding is also known as partitioning, specifically horizontal partitioning. A key, or combination of keys is picked and subsequently used to create logical groupings of data. These data represented by these groupings can then be spread across many hosts to enable horizontal scaling across smaller (generally less expensive) hosts rather than using progressively more powerful (and expensive) hosts for the database as utilization increases.

Generally one or more grouping will reside on a particular host (or set of hosts) and that will then be referred to as a shard.

When accessing the data (or adding new data), there must be a mechanism whereby the application, user, DBA etc. can determine where data currently resides or should be placed based on the sharding scheme. This may be implemented many ways - lookup tables, range based partitioning, consistent hashing schemes, hash maps and various others.