Logical Architecture Design of Database in SaaS & Multi-tenant Scenarios
Logical Architecture Design of Database in SaaS & Multi-tenant Scenarios
Preface
If you want to use a distributed database in a normal multi-tenant application, what important requirements would you consider?
The answer is obvious: performance, security, manageability, and scalability. These four requirements are common and important in all multi-tenant applications.
Why?
Basic principles:
Performance assurance: Avoid cross-database operations and cross-node operations.
Security: Isolation between users.
Manageability: Support application flexibility, business adjustments, data migration, backup and restore.
Scalability: Support business elastic expansion.
Klustron's Logical Architecture in SaaS
As a cloud-native distributed database, Klustron is very suitable for use in SaaS application scenarios. The following figure shows the logical architecture of a SaaS software service that uses Klustron.

The main steps in designing this logical architecture are as follows:
Create a database user and database schema for each customer. The database user is the username used by the application to connect to the database and has permission to access the corresponding database schema. (In the example, the database user SCH1 and the database schema SCH1 are a combination, and the user SCH2 and the database schema SCH2 are another combination for another business user.) This design ensures the isolation between different users.
In the database cluster, create a database for each application to ensure that the same application uses the same database. Create different schemas in each database to serve different customers.
Design tables for each schema, which are divided into three types: regular tables, sharded tables, and replicated tables. Tables with less than 10k rows are not sharded and are stored in a specific storage data node. All large tables are sharded based on the data size and query scenarios, using range, list, hash value, or related table reference fields. Tables with very small data sizes and frequently used are created as replicated tables, with a copy stored on each node of the storage cluster.
Conclusion
Klustron's unique architecture makes it an excellent choice for building SaaS applications. The two are a perfect match.