100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Database Sharding: Scaling Databases Efficiently $4.79
Add to cart

Other

Database Sharding: Scaling Databases Efficiently

 0 purchase

This document explains database sharding, a technique used to split large databases into smaller, faster, and more manageable parts. It covers how sharding improves scalability, performance, and availability in distributed systems. The guide also discusses different sharding strategies and their im...

[Show more]

Preview 2 out of 6  pages

  • January 30, 2025
  • 6
  • 2024/2025
  • Other
  • Unknown
All documents for this subject (249)
avatar-seller
rileyclover179
Database Sharding
1. Introduction to Sharding
Sharding is the process of splitting a large database into smaller, more
manageable pieces, called shards, and distributing them across multiple servers.
Each shard is a subset of the data, and together, the shards make up the entire
dataset. Sharding is primarily used to scale databases horizontally, improving
performance and enabling databases to handle increased data and traffic loads.

Sharding is often used when a single server is no longer sufficient to store or
manage all the data due to limitations like storage, processing power, or network
bandwidth.



2. Why Use Sharding?
Sharding helps in the following scenarios:

 Handling Large Datasets: As datasets grow larger, it becomes increasingly
difficult to manage them on a single server. Sharding breaks down the data
into smaller parts, each stored on a different server.
 Improved Performance: By distributing the data, read and write operations
can be processed in parallel, improving overall performance and reducing
bottlenecks.
 High Availability: When data is distributed across multiple servers, the
failure of one server doesn’t affect the entire dataset, increasing system
reliability.
 Scalability: Sharding makes it easier to scale the system by adding more
servers as the dataset grows.



3. Shard Key and Partitioning
A shard key is the key used to determine how the data is distributed across the
shards. The choice of shard key is critical because it dictates how efficiently the

, data is spread across servers and how queries are handled. A good shard key
ensures that the data is evenly distributed and that the queries can be processed
in parallel across different shards.

Types of Partitioning (Sharding)

Sharding can be done using several partitioning strategies, depending on how the
data is distributed:

a. Range-based Sharding

 Description: In range-based sharding, the data is divided into ranges based
on the shard key. For example, if the shard key is a customer ID, each shard
might store data for customers with a specific ID range (e.g., 1-1000, 1001-
2000).
 Use Case: This is useful when data is distributed in a natural way along a
continuous range, such as timestamps or numerical IDs.

Example:

 Shard 1: Customer ID 1-1000
 Shard 2: Customer ID 1001-2000
 Shard 3: Customer ID 2001-3000



b. Hash-based Sharding

 Description: In hash-based sharding, a hash function is applied to the shard
key to determine which shard the data should go to. The hash function
ensures that the data is evenly distributed across the available shards.
 Use Case: This is ideal when the data does not follow a natural range and
when a uniform distribution of data is required.

Example:

 Shard 1: Hash(Customer ID) mod 3 = 0
 Shard 2: Hash(Customer ID) mod 3 = 1
 Shard 3: Hash(Customer ID) mod 3 = 2

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller rileyclover179. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $4.79. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

66456 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 15 years now

Start selling
$4.79
  • (0)
Add to cart
Added