• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 2 fuera de 6 páginas
Otro

Database Sharding: Scaling Databases Efficiently

Document preview thumbnail
Vista previa 2 fuera de 6 páginas

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 impact on database efficiency.

Vista previa del contenido

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

Información del documento

Subido en
30 de enero de 2025
Número de páginas
6
Escrito en
2024/2025
Tipo
Otro
Personaje
Desconocido
$5.29

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Vendido
0
Seguidores
0
Artículos
252
Última venta
-




Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes