Vertical sharding allows you to spread your database tables out across multiple servers. During the vertical sharding process, you would look at all the tables in your database and, based on their characteristics, designate one of your many servers for each table to reside on. Some servers may house a single table if it is large or in very high demand, whereas others may contain multiple smaller tables.
Let's consider the database for GalaxySurfer and how we might apply vertical sharding to this database to help the company scale.
If the two tables being inserted into or modified the most are the inventory
table and the message
table, then we may want to put these in separate vertical shards. This allows Juniper Studios spread traffic out across multiple servers. These servers act as their own primaries, each running a separate instance of MySQL. This means that we can have two separate databases representing our app model. With these two servers in place, the storage, compute resources, and so on can be managed independently.
We can also use row-splitting techniques to divide up the data further. Combining vertical sharding with row-splitting can be a solid way to scale a database.
In a vertically sharded setup, you have more infrastructure to manage, monitor, and keep online. Overall, there are more points of possible failure. If you have split up your database across 10 separate primaries, and then each of those has one or more replicas, that's a lot of servers to manage, take backups of, etc.
Another challenge comes when you need to execute tasks or queries that require data from multiple servers. This is especially true when using tables that have been row-split.
The technique you use in vertically or horizontally sharding a database is super important. A poorly sharded database can lead to abysmal performance. There is a lot to consider, including the size of your database, its schema, and the workload it is handling.
PlanetScale uses Vitess, which has a superb architecture for managing shards. Through Vitess, we can support both vertical and horizontal sharding, and allow our customers to combine the two approaches.