Scaling horizontally is a shift away from the single-primary mentality. Instead, the data is spread across multiple primary instances, which allows the query load to be spread across multiple machines for both read and write operations.
One option for horizontal scaling is to move away from a multi-tenant configuration to a single-tenant one. This means you split up your single databases into multiple with a similar schema.
Sharding is a methodology that many huge Enterprise organizations use and trust to work for incredibly high demand. It is also the technique that Vitess/PlanetScale uses to help large organizations scale. There are two types of sharding — vertical sharding and horizontal sharding.
Vertical sharding involves spreading out the tables of your database across multiple servers. For example, we want the messages table to live on one server, the players table to live on another server, and the rest of the tables to be housed on a third server. Any given table lives on one server, but all our data is spread across multiple primary instances.
Horizontal sharding also involves spreading the data across multiple servers but is done using a different technique. Instead of splitting the data by table, each database row is assigned to a server based on a sharding key. For example, all messages with IDs 0-1 million go to one server, 1-2 million to another server, 2-3 million to another, and so on. There are many different ways to shard a database, which will be discussed later.