An intro about single tenant architecture & multi tenant architecture
A single-tenant architecture (siloed model) is a single architecture per organization where the application has its own infrastructure, hardware, and software ecosystem.
Multi tenant architecture is an ecosystem or model, in which a single environment can serve multiple tenants utilizing a scalable, available, and resilient architecture. The infrastructure is completely shared, logically isolated, and with fully centralized services.
Types of Multi tenant SaaS architectures
- Application layer Multi-tenancy
- Database layer Multi-tenancy
Application layer Multi-tenancy
Examples
- Monolithic architecture for SaaS
- Microservices Architecture for SaaS with containers
- Kubernetes Architecture for SaaS
- Serverless Architecture for SaaS
Database Layer Multi-tenancy
When choosing database architecture, there are multiple criterias to assess. The criterias are Scalability (Number of tenants, storage per-tenant, workload), Tenant isolation, database costs (per tenant costs), development complexity (changes in schemas, queries, etc.), and operational complexity (Database clustering, update tenant data, database administration, and maintenance).
Examples
1. Single database: A table per tenant
Known as DB pooled model.
It consists of leveraging a table per each organization within a database schema. Every table name has its own tenantID, which is very straightforward to design and architect.
Pros
- Easy to scale
- Great for thousands of tenant
Cons
- Difficult for backup & recovery
- Poor data isolation
- Performance degradation (one tenant can overuse compute and ram resources from another)
2. Single Database: A schema per tenant
Known as the bridge model.
If there is more than 100 schemas or tenants within a database, it can provoke a lag in database performance. Hence, it is recommended to split the database into two (add the second database as a replica). The best database tool for this approach is PostgreSQL, which supports multiple schemas without much complexity. This strategy shares resources, compute, and storage across all its tenants.
Pros
- Less development complexity
- Secure than DB pooled model
- Can customize schemas per tenant
Cons
- This architecture not comply with PCI / HIPPA / FedRamp regulations
- Medium tenent isolation
3. Database Server Per Tenant
Also known as Siloed model.
Now we need a database instance per customer. Expensive, but the best for isolation and security compliance.
Pros
- High data isolation
- Widely used and accepted
Cons
- More cost
- Complex to manage dozens DB server
Got a project in mind? Send me a quick message, and I'll get back to you within 24 hours!.
Recent Posts
- Disabling Payment Methods in WooCommerce Based on Conditions
- How to Update Product Quantity in WooCommerce Using Custom Code
- Dynamically Generating a Table of Contents in WordPress
- Direct Checkout in WooCommerce - Add Product to Cart from Checkout Page & Skip Shop, Product, and Cart Pages
- Understanding the Impact of git reset --hard Command
Your Questions / Comments
If you found this article interesting, found errors, or just want to discuss about it, please get in touch.