PlanetScale supports both vertical and horizontal sharding with Vitess. In this lesson, let's look at some pre-configured sharded databases.
In Vitess terminology, a keyspace refers to a separate logical database. In the first example, you can see an example of a database split up into two keyspaces. The message
table will get its own separate MySQL server (in its own keyspace) and the other eight tables will be housed in a separate keyspace. This means that I can send the traffic for the message
table to one primary server and all of the other traffic to another. In the PlanetScale UI, you can see that each keyspace has a dedicated primary and two replicas.
In the second example, the database has one keyspace that is divided up into two shards for the message
table. In this configuration, there could be a greater capacity to handle a high volume of reads and writes to the message
table since multiple servers can process write requests into the message
table.
In this third and last scenario, you can see an example of a table split up across four shards. This configuration provides even greater scaling capacity than the previous one, as the contents of the table are divided up amongst even more shards. If the message
table grew to be 1 terabyte, it could be divided up into approximately 256 gigabyte chunks for each shard. As the table continues to grow, more shards could be added.