Multi-tenancy vs Single-tenancy application architecture
Tags: webdev, backend, architecture, database
Published: 2021-12-20 15:26:09

## What is multi-tenancy?

Multi-tenancy is a software architecture that let a single software deployment serve multiple tenants. Application resources are shared among all tenants however, each tenant has guaranteed data isolation and privacy.


![Image Multi-tenancy](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r8rpffb7i1g13ejsbyd9.png)

&nbsp;
## What is single-tenancy?
Single tenancy is an architecture that enables one tenant per instance of the software. Every new tenant will need new instance of application.


![Image single-tenancy](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y37qcr1iz26sn10p8vdg.png)

&nbsp;
## Pros and cons of multi-tenancy architecture
&nbsp;
### Pros:

- **Applications are easy to deploy**
	The application can be deployed and managed as one instance of software application. One instance of application could serve all customers.
	
- **Lower cost** 
Multi-tenancy architectures allow for efficient usage of compute and hardware resources as they all being shared which reduces overall cost.

- **Single software instance is much easier to maintain, secure, and optimize.**
The multi-tenant application architecture is designed in such a way that it makes it much more efficient to manage.

- **Fast Scaling** 
Adding new customers should be effortless and achievable within a software application. It does require extra configuration or spinning new containers.

&nbsp;
### Cons:

- **Design & Development**
	Designing a multi-tenant application may be challenging as it requires considering data segregation for a single entity and Cross tenant access where some tables may need to be accessed by multiple customers.
- **Higher Security Risk**
	In case of a data breach or security vulnerability, all customer data can be damaged.
	
-   **More downtime**
	Multi-tenant application can experience more downtime.When the application is maintained or updated more customers may be affected by downtime.

&nbsp;
## Single-tenancy architecture pros and cons
&nbsp;
### Pros:
- **Improved Security**
As single-tenant application lives in an isolated environment it is more secure and independent therefore, it increases customer's data protection.

- **Easy to restore & backups**
	In the single-tenant system, the tenant can manage updates by downloading and upgrading local applications. When configuring backups and recovery options, this model allows for better overall control. This lets manage client individual backups more efficiently as each backup can be done separately.
	
- **Individual Upgrades/Updates**
  The application can be upgraded/Updated separately without affecting other customers.
  
- **Self-Hosted migration** - Tenant will have the option to migrate an application or change hosting provider. Software instances could be migrated from the cloud to on-premises if requested.
&nbsp;

### Cons
- **Resource underutilized**
Often underutilized resources are a common issue when running multiple instances as each tenant needs a new software instance with allocated resources.

- **More effort to deploy**
Single-tenant applications take more time to deploy, as each customer gets a separate instance running.

- **Higher costs**
The cost of ownership and maintenance is a lot higher.

- **Number of instances grows quickly**
Adding a new customer requires adding a new instance, which means more resources and more costs.

- **Difficult to manage**
Maintaining, securing, and optimizing multiple software instances is difficult, and requires a much bigger team.

&nbsp;
To sum up, both single tenancy and multi-tenancy architectures have their pros and cons. Security-wise single-tenant architecture is the preferred option. On the other hand, when cost-efficiency is highly considered by the business multi-tenant architecture is a better option. Multi-tenant application adds additional complexity and development effort as it needs to maintain metadata for each tenant. The initial development time of multi-tenant can be much longer compared to single-tenant application.