Let's consider the structure of a chat application as an example. Think of an application like Slack, Discord, and other similar platforms. There are generally many users on these apps, and each user can be a member of one or more servers or groups. Each group has a bunch of associated data isolated from other groups, such as the list of members, channels, settings, file uploads, and, of course, the messages themselves.
One way to store this data would be to have all groups share the same giant, unified server in the background. If millions of people were using our chat app, our database could quickly grow to a trillion+ rows of information. In these setups, users are often only using one group at a time, and so to get group-specific information, you would have to keep track of group_id
or workspace_id
for many of my rows and will do lookups based on those.
Another option would be to set this up in a single-tenant configuration. In this configuration, each tenant (chat group) would get its own separate MySQL database to store all pertinent information: settings, members, messages, uploads, etc.
Utilizing a single-tenant approach is a method of horizontal scalability since you can split your workload across multiple database servers. Instead of having one gigantic database with potentially tens or hundreds of terabytes of data, each of your thousands of chat groups can be given a separate MySQL server instance housed on a separate virtual machines in the cloud. This helps with scalability, though at the cost of added complexity.
Since your customers' data is split across many database servers but accessed from the same UI, you'll need a routing system to determine where the data for a given customer lives. When a user switches from one chat group to another, you'll have to have logic to know how to connect to the appropriate server for that user. This configuration is likely to have a more complex architecture, depending on how many servers you have. This issue is compounded if you decide to add other scalability approaches like partitioning or replication.