What is multi-tenancy in software

Introduction

Welcome to first my blog on multi-tenancy in software. In this blog we will deep dive into the exciting world of multi-tenancy.

Key challenges in building multi-tenancy applications are isolation, security and managing database connections efficiently. Each tenant requires its own database connection or connection pool to ensure data isolation and security.

What is Multi-tenancy

Multi-tenancy refers to a software architecture where a single instance of the software application serves multiple tenants, or customers. Each tenant operates as if they have their own isolated instance of the application, with their data and configurations separated from other tenants. Each tenant data and configuration isolated from other tenants but they share same infrastructure including application instance, hardware, software and database.

Multi-tenancy is commonly used in cloud-based software services, where it allows providers to efficiently serve multiple customers while minimizing infrastructure costs. It is also prevalent in Software as a Service (SaaS) applications, where a single code base serves multiple customers with customization options for each tenant.

Why Multi-tenancy

Multi-tenancy provides solution to multiple NFRs (Non Functional Requirements) - 

Types of multi-tenancy

Software architects and developer implement many types of multi-tenancy in current real world using cloud setups, dockers, new generation databases but following are the major types of multi-tenancy -


Database-per-Tenant: 

In this type, each tenant has its dedicated database instance. This approach provides the highest level of data isolation and security since each tenant's data is physically separated. However, it can be resource-intensive and may result in higher infrastructure costs, especially for large-scale applications with numerous tenants.

Schema-per-Tenant: 

In this model, all tenants share a single database instance, but each tenant has its schema within that database. This approach offers a balance between data isolation and resource utilization since tenants' data is logically separated within the same database. It's more efficient than the database-per-tenant model in terms of resource utilization but still provides a reasonable level of data isolation.

Shared Database with Shared Schema: 

In this model, all tenants share the same database and schema. Data segregation is achieved through application logic, such as using a tenant identifier column in each table to distinguish between tenant-specific data. While this approach is the most resource-efficient, it requires careful implementation to ensure data isolation and security. In this implementation developers have to be very careful whenever writing database queries and handling data in services to make proper isolation.

Shared Database with Separate Data Tables: 

This model involves sharing a single database with a separate set of tables for each tenant. Each tenant has its tables within the same database, ensuring data isolation. This approach is more resource-efficient than having separate databases for each tenant but provides a higher level of data isolation compared to sharing a single schema.

Virtual Tenancy: 

In this model, tenants share the same application instance but have their isolated virtual environments within the application. Virtual tenancy is often used in cloud-based environments, where tenants share the same underlying infrastructure but have separate configurations, resources, and access controls within the application.

Conclusion

In this blog we have seen what is multi-tenancy why multi-tenancy is important and what are the different types of multi-tenancy.

In conclusion, this blog can be referred as a introduction to multi-tenancy in software.


In the next blog we will explore how to implement multi-tenancy in springboot applications.



Yogesh Kulkarni