Andres Duque Hincapie

Software Engineer, Entrepreneur and passionated by technology.

@saduqz

Single-Tenant

Vs

Multi-Tenant

Single-tenant Architecture

What is?

System wherein each customer has their own independent database and instance of the software

Some

Advantages

  • Security
  • Data backup
  • migration to a self-hosted environment

Multi-tenant architecture

What is?

A single instance of an application, server, and infrastructure is shared across multiple clients (tenants).

Also shares a multi-tenant database

Apartments like a perfect example of a multi-tenant architecture

Single-Tenant                        Multi-Tenant

When to use?

Businesses and organizations need SaaS for a lower cost and optimum efficiency.

SaaS

Software as a Service

What is?

Provide application and makes them available to customers across the internet instead of manual and physical installations.

Each of these has its pros and cons

We will see scenarios wherein multi-tenancy is better than single tenancy

1. Investment cost to decrease in the long run

Sharing resources

  • Databases
  • Application itself
  • Server
  • Infrastructure

Total costs are shared by multiple tenants sharing the application

Easier to deliver a SaaS solution

2. Maintenance, Updates, and Upgrades

Needs to be done at just one centralized point but is reflected at all tenant ends

This reduces the overall cost of maintenance for each tenant.

3. Onboarding of New Tenants

Customers and users on board for using the product is a crucial task

Configuration of subdomain/domain are automated

Automatically performs tasks like the setup of default data for clients and configuring of application

4. Scalability

As more hardware is added to a multi-tenant SaaS model the horsepower of the entire system is powered up

There is no need for raising the number of data centers for the individual tenants

4. Service Support

The provider needs to administer just one platform that hosts multiple tenants

Conclusion

It depends!

Time to Have Fun

Only works with PostgreSQL

What are schemas?

A schema can be seen as a directory in an operating system, each directory (schema) with it's own set of files (tables and objects). This allows the same table name and objects to be used in different schemas without conflict. For an accurate description on schemas, see PostgreSQL’s official documentation on schemas.

 

Why schemas?

There are typically three solutions for solving the multi-tenancy problem.

1. Isolated Approach: Separate Databases. Each tenant has its own database.

 

2. Semi-Isolated Approach: Shared Database, Separate Schemas. One database for all tenants, but one schema per tenant.

 

3. Shared Approach: Shared Database, Shared Schema. All tenants share the same database and schema. There is a main tenant-table, where all other tables have a foreign key pointing to.

The ideal compromise between simplicity and performance

How it works?

Tenants are identified via their hostname.

 

client-2.domain.com

client-2.domain.com

Multi tenant architecture

By saduqz

Multi tenant architecture

  • 812