(877) 519-4537 info@arkware.com

Any custom database application that sees significant growth will eventually need to scale in order to handle an increase in traffic. It’s important that this is done in a way that protects the integrity and security of the data. For this reason, many database management companies recommend sharding. 

Sharded databases have received a lot of attention in recent years, but this doesn’t mean that they’re right for everyone. In this article, we’ll go into greater detail regarding sharded databases so that you can have a clear idea of what they are and if they’re right for your organization. 

What is Sharding? 

Sharding is a database architecture pattern that’s similar to horizontal partitioning, which is the practice of separating one table’s rows into multiple different tables. These tables are known as ‘partitions.’ Each partition has the same schema and columns, but entirely different rows. The data contained in each row is unique and independent of the data contained in other partitions. 

The purpose of sharding is to break data up into smaller chunks. This way, your application can make fewer queries. For instance, when your database receives a request, the application will know where to send the request. It has far less data to look through because it doesn’t have to go through the whole database. 

Sharding Architectures 

There are a few different ways you can shard your database. It’s important that everything is set up correctly, as you want your queries to go to the correct shard. Otherwise, you could end up with slow queries and lost data. 

Key based sharding 

Key based sharding uses a value taken from newly written data and plugs it into a ‘hash function’ to determine which shard the data should go to. This method is common and can protect data from uneven distribution. 

Range based sharding 

Range based sharding involves sharding data based on ranges of a given value. It’s simple to implement, but it doesn’t protect data from being distributed unevenly. 

Directory based sharding 

Directory based sharding requires you to create and maintain a ‘lookup table’ to keep track of which shard holds which data. The benefit to this method is that it’s flexible. 

Database sharding can be a great solution if you’re looking to scale your database horizontally. To learn more about sharding, if it’s right for you and the best architecture to use, contact Arkware today