July 15, 2025
by Washija Kazim / July 15, 2025
There’s a stage in every system’s growth where traditional database architecture stops working. Queries slow down. Write throughput hits a ceiling. Replication helps for a while, but eventually, the limits of vertical scaling become unavoidable.
At this point, teams have to make a strategic decision: re-architect the database for scale or risk performance degradation and operational fragility.
Database sharding offers a way forward. It’s the practice of splitting a large dataset into smaller, independent partitions, known as shards, and distributing them across multiple servers. Each shard holds a portion of the overall data, allowing applications to scale horizontally by distributing reads, writes, and storage across infrastructure instead of centralizing them in one system.
Database sharding becomes necessary when your application outgrows the performance, storage, or availability limits of a single-node database. It works by splitting your dataset into discrete chunks (shards) and distributing them across multiple servers, allowing reads and writes to scale horizontally without centralized bottlenecks.
Sharding typically builds on top of relational databases, which organize data into rows and columns and are commonly used for structured application data. But when a single relational database instance can no longer support growing traffic or evolving compliance needs, sharding becomes the next step. It distributes subsets of that structured data across nodes, maintaining relational logic while addressing bottlenecks in storage, performance, and fault tolerance.
Whether you’re evaluating sharding for the first time or preparing to implement it, this guide explores the infrastructure behind it, when it makes sense, and how companies like PayPal, Dropbox, and Salesforce use it in production.
Sharding isn’t a decision you make on a whim. It introduces operational complexity, so it’s worth doing only when the benefits clearly outweigh the overhead.
Here’s how to evaluate whether your database is at the point where sharding is necessary and likely to deliver performance or scaling gains.
You don’t need to wait for system failure before you shard, but you should look for tangible signs of stress across storage, performance, or uptime. These include:
These symptoms suggest you’re approaching the ceiling of what a single-node or vertically scaled system can manage.
Even if you’re facing some of the above issues, it’s important to check whether your data model and usage patterns are a good fit for sharding.
Timing your sharding implementation can have long-term consequences. Adopt it too soon, and you might be burdened with unnecessary complexity. Wait too long, and your systems could buckle under the weight of scale, making the transition far more painful.
Premature sharding is a form of early optimization, and it often stems from anticipating a scale that may never arrive. This can lead to:
Delaying sharding until your system is overwhelmed can make migration much harder and riskier. Key challenges include:
It’s crucial to consider whether database sharding is the next best move for your database architecture. Some of the significant potential challenges of sharding are:
When determining whether sharding is the right fit for your database, it’s critical to account for the operational complexities of implementing and maintaining multiple shards. Rather than managing a single database, developers must manage shards across many computers, which forces them to query several shards to combine the right pieces of information as needed. Effective database sharding requires choosing the right sharding key and method to support the dataset.
Some queries may span multiple shards, and cross-shard queries can be slower as more work is required to coordinate data. If performance slows when managing complex, cross-shard queries, this can lead to a poor user experience. When user experience suffers from cross-sharding, it eliminates the benefits of improved performance and load distribution that sharding can provide.
For some enterprises, re-sharding existing data or migrating data between shards for rebalancing purposes can be highly complex and resource-intensive. Migrating data requires careful planning and consideration, including strategies for minimizing operational disruption during the data migration.
At the infrastructure level, sharding breaks your dataset into discrete, physically independent databases, called shards, and spreads them across multiple nodes. Each shard stores only a portion of the overall data but uses the same schema, allowing distributed systems to scale without duplicating the full dataset on every server.
Here’s how the core components of a sharded system come together:
These components work together to deliver scalable, distributed access without bottlenecking a single instance.
Sharded systems rely on the principle that not every query needs to scan every row. By narrowing requests to a specific shard based on the key, the system avoids centralized bottlenecks and achieves true horizontal scale. But that performance gain depends entirely on how well the sharding logic maps to your application’s data access patterns.
Each sharding method comes with its own logic for distributing data and each introduces different tradeoffs around performance, flexibility, and operational complexity. The method you choose should match your data model, query patterns, and long-term scalability goals. The wrong sharding strategy can lead to uneven load distribution, excessive cross-shard traffic, or costly rearchitecture later.
Ranged, also known as range-based or dynamic, is a sharding method designed to partition data using a field in the database and a predefined range of values to assign the record to a shard. It splits database rows based on the defined range of a value.
For example, consider a dataset with a column containing users’ birth months. We might separate the birth month ranges:
Birth month range | Shard ID |
January-April | 1 |
May-August | 2 |
September-December | 3 |
Ranged sharding should help disperse data for more efficient queries. However, in this example, given that August is the most common birth month, the server hosting Shard ID 2 may experience added pressure because of a disproportionate load.
In hashed sharding, a hash function, or mathematical equation, is applied to a shard key to determine how to distribute the data across different shards. This method takes a record from the database as input (some examples include the customer name, birthdate, zip code, or order number) and applies a hash function to it. Then, it uses the output, or hash value, to allocate the record to the corresponding shard.
Altogether, an example is taking a value such as a leader’s name and applying the hash function to determine hash values as follows:
Name | Hash Function | Shard ID |
Kenji | *Hash function applied* | 1 |
Leila | *Hash function applied* | 2 |
Priti | *Hash function applied* | 3 |
Marco | *Hash function applied* | 1 |
Ben | *Hash function applied* | 2 |
Priya | *Hash function applied* | 3 |
Hashed sharding works well for dispersing information in a database among multiple shards. However, the con of hashed sharding is that it’s a more complex method than the others. Each time you add a new server, you must also add a corresponding hash value, which may require some remapping of existing entries for accuracy.
Relationship-based sharding organizes data based on relationships among data entities. This method works well for systems where specific data points benefit from groupings. For example, you might shard data based on customer segments, with customers categorized as small, medium, and large businesses:
Business Size | Shard ID |
Small | 1 |
Medium | 2 |
Large | 3 |
The system directs the request to Shard 2 when executing a query to retrieve data for medium-sized businesses, ensuring efficient access to all related data. Relationship-based sharding optimizes performance by localizing associated data in the same shard, reducing the need for queries that require information from multiple shards.
Geography-based sharding is a technique that partitions data based on geographical location, allowing applications to optimize performance and compliance with regional regulations. Companies may want to use customer location to shard data, enabling them to store data in a data center near the area for reduced latency. Here, the location shared, such as the state or country, is the shard key. For example, suppose a content streaming service uses geo-sharding to store data:
Customer Location | Shard ID |
North America | 1 |
Asia | 2 |
Europe | 3 |
This setup reduces latency by serving users from the nearest shard and helps comply with data sovereignty laws. When a European user requests content, the system retrieves data from Shard 3, ensuring a faster response time and enhancing the overall user experience. Geo-sharding is valuable for applications with a global user base, enabling efficient data distribution and localized access.
Sharding allows growing systems to bypass the limits of vertical scaling by distributing data and compute horizontally. But the benefits aren’t just theoretical — they show up in how systems perform under real-world load, failure conditions, and geographic distribution.
Distributing data across shards reduces the total volume each server has to manage. This allows queries to execute against smaller, isolated datasets instead of scanning a monolithic table. With the right shard key, read and write operations hit only the relevant partition, improving response times even as data volume grows.
In high-concurrency systems, this reduction in scope helps maintain low-latency performance, especially during peak traffic.
Sharding separates data and traffic into logical units, so a spike in one shard doesn’t impact others. For example, if one tenant runs a resource-intensive operation, its load is confined to its shard, preserving system stability for everyone else.
This isolation is essential for multi-tenant SaaS platforms and regionalized apps that need to enforce performance boundaries between workloads.
When a monolithic database reaches its storage or compute limits, scaling usually requires downtime, schema changes, or expensive hardware. Sharded systems avoid that by allowing new nodes to be added incrementally.
As usage expands, new shards can be provisioned without touching existing data or interrupting availability; a major advantage for teams managing global growth or unpredictable traffic.
Sharding by geography lets you store data closer to where it’s generated or consumed. This improves performance for end users and supports compliance with regulations like GDPR, HIPAA, or data residency laws.
It’s especially valuable for platforms operating across jurisdictions or serving a global customer base, where both latency and legal requirements vary regionally.
If you’re still unsure whether database sharding is suitable for your database architecture, take a look at these sharding applications from well-known companies like Dropbox, PayPal, and Salesforce for a better idea of use cases.
Dropbox, a cloud-based storage service that enables users to store, share, and access files across devices, uses Edgestore to store metadata. Edgestore offers the ability to collocate related data items on the same shard, but Dropbox found that not all of its product use cases made sense for collocation.
Daniel Tahara, a former software engineer at Dropbox, said, “As a simple example, an association between a user and the content they share with another user is unlikely to be collocated since the users likely live on different shards. Even if we were to attempt to reorganize physical storage such that related colos land on the same physical shards, we would never get a perfect cut of data.”
To combat this, Dropbox deployed cross-shard transactions, which allowed transactions across colos. This allowed the Dropbox team to change their application for the better while maintaining trust and safety with their users.
PayPal uses JunoDB, an open-source, distributed key-value store, to serve billions of daily requests and support active customers and payments. While there’s a lot to learn and understand about JunoDB’s architecture, notably, it supports sharding, or partitioning, based on consistent hashing. When using JunoDB, shards get distributed to physical storage using a shard map.
According to an April 2024 edition of the ByteByteGo Newsletter, PayPal uses 1,024 shards, and the shard map is pre-generated and stored accordingly. This is one of many aspects of JunoDB that enables PayPal to deliver high availability.
In March 2024, Ian Varley, Salesforce's principal architect, posted on Salesforce’s blog about how the company uses sharding to scale its technology stack. Varley explains that earning trust and providing stable and responsive service are essential as companies like Salesforce grow and support more customers.
Regarding scaling their database architecture, Varley said, “Salesforce, on the other hand, is a multi-tenant system. That means we actually have a really simple way to do it: we shard by customer organization. The organization (or “org” for the cool kids) is a totally self-contained unit. No data ever traverses the boundary between orgs, except by coming out the front door of one org and in the front door of another, using proper authentication.”
Sharding is not a plug-and-play solution. It requires a deep understanding of your data, thoughtful design of shard keys, careful planning around migration, and tooling to manage operations post-implementation.
Here’s what it takes to implement database sharding in the real world.
Start by evaluating your data access patterns and schema structure. Your choice of sharding method directly impacts query performance, resilience, and operations:
Choosing the wrong sharding strategy often results in long-term performance penalties or increased query complexity.
The shard key determines how data is distributed. A good shard key:
Before going live, simulate or test your shard key using production-like data volumes to catch imbalances early.
You’ll need a mechanism for:
Some distributed databases provide built-in sharding and routing layers. In others, you’ll need to build this abstraction.
Migrating from a monolithic DB to a sharded architecture is often the most delicate phase. Consider:
Avoid Big Bang migrations unless absolutely necessary. Dropbox and PayPal, for example, implemented cross-shard support only after extensive internal testing and gradual rollout phases.
Once live, your team must monitor and manage shards just like you would any other distributed system:
Sharding moves complexity from the database to your application and ops teams. Plan accordingly and invest in tooling early.
Sharding isn’t a nice-to-have. It’s a structural decision that becomes necessary when your system reaches a point where vertical scaling can no longer sustain performance, availability, or growth. It’s how distributed systems survive under pressure but that doesn’t mean it’s easy, or always the right call.
If your application is showing signs of saturation — rising latency, lock contention, or regional compliance challenges — sharding can offer a path forward. But the shift comes with tradeoffs. You’ll need the right shard key, a solid routing strategy, operational readiness, and the discipline to avoid introducing cross-shard complexity that erodes the very gains you’re after.
Before you shard, make sure your data is protected. Learn why database backups remain a critical layer in any scaling architecture.
Washija Kazim is a Sr. Content Marketing Specialist at G2 focused on creating actionable SaaS content for IT management and infrastructure needs. With a professional degree in business administration, she specializes in subjects like business logic, impact analysis, data lifecycle management, and cryptocurrency. In her spare time, she can be found buried nose-deep in a book, lost in her favorite cinematic world, or planning her next trip to the mountains.
Companies that need online transactions cannot afford server breakdowns. As a result, these...
Here’s a riddle: what does a box of Legos and the future of technology suites have in common? ...
Think about your favorite gaming gadget.
Companies that need online transactions cannot afford server breakdowns. As a result, these...
Here’s a riddle: what does a box of Legos and the future of technology suites have in common? ...