Professional Documents
Culture Documents
What Is A Multi-Tenant systemDEV
What Is A Multi-Tenant systemDEV
What Is A Multi-Tenant systemDEV
- DEV
Say that I want to host my own email and document server. After much search I choose owncloud1. I install it on my
own server. I create one account for myself and I use it. This is a single-user, single-tenant system. I'm the user as
well as the tenant. I can make whatever modification I want on the system.
Want to host it on a separate domain? Check.
What to change the colors in the system? Check.
What to pick and choose modules? Check.
As I get used to this system, I want to share the calendar with my wife and family. I create individual accounts for each
of them. Now the system becomes multi-user, but it is still single-tenant. Each user can customize few features, like
calendar name, but they can't pick and choose a functionality. If my sister wants to sync this calendar with her gmail
calendar, she can't. Why? Because if I enable it, it will be enabled for all and I don't want to confuse my father with a
new option. There is no option to enable it only for one user or set of users.
Now my colleagues Martin and Bob are impressed with how I manage my family schedule and they want to do the
same. I could install owncloud in their own server. They will get the freedom to customize the way they want. But they
don't want the headache of managing their servers and monitoring them. So they ask me to manage for them. They
also tell me, they don't want to share their data with anyone else. They ask me if I could set up independent data
storage for them. It doesn't stop. Martin wants only calendar facility and want to access the system via
schedules.martinfamily.com. Bob on the other hand, wants to access the system from familyroom.bob.com. As
indicated by the url, he wants to store family documents in addition to using calendar. He wants AWS S3 to be his
data store. I can setup all of these because Owncloud supports multi-tenancy. They are pleased with the setup and
invite all their family members to use the system. They decide to pay me for my service. I charge them according to
the usage instead of a flat rate. (I wish I could end the story like the fairy tales: I lived happily ever after in Hawaii :-) ).
This setup is now a multi-user, multi-tenant system.
As you can understand, not all web applications have to be multi-user system and not all multi-user web-applications
32 2 15
have to be multi-tenant system. All solutions are contextual. An architect has to select the right approach for a given
https://dev.to/jjude/what-is-a-multi-tenant-system-bpd 2/8
28/12/2020 What is a multi-tenant system? - DEV
set of requirement.
Architecting a multi-tenant system is more complicated than architecting a multi-user system. There are two models
of architecting a multi-tenant system: instance replication and data-segregation.
In instance replication model, the system spins a new instance for every tenant. This is easier to start, but hard to
scale. It becomes a nightmare when 100s of tenants signup.
32
In data-segregation 2
model, the application is shared 15 of each tenant is stored in separate
between tenants but data
d t t S t d t t
https://dev.to/jjude/what-is-a-multi-tenant-system-bpd ld b t d t b t h ithi th d t b 3/8
28/12/2020 What is a multi-tenant system? - DEV
data stores. Separate data stores could be separate databases or separate schema within the same database.
To support such data-segregation, there has to be an additional management layer in the system architecture to
provision a separate data-store every time a tenant signs up. Multi-tenancy includes customized UI for each tenant,
selective subscription of services, and metered billing. This management layer is responsible for all of these functions.
By now it should be obvious that multi-tenant systems are not appropriate for every web-application. A multi-user
32 2 15
architecture is sufficient enough for a B2C (business-to-customer) web-application. A multi-tenant architecture should
https://dev.to/jjude/what-is-a-multi-tenant-system-bpd 4/8
28/12/2020 What is a multi-tenant system? - DEV
Even though a multi-tenant architecture is a complex one, data privacy regulations like GDPR will force most B2B
SAAS applications to become a multi-tenant system. If you are building a new B2B SAAS application, you better
start with a multi-tenancy architecture.
Discussion Subscribe
There's a third model for data segregation: a single schema in a single database, with data identified as
belonging to one or another tenant by a key column. Usually the key can be traced back to a table
representing all tenants in the system. If you set up foreign keys appropriately, you only need the tenant id in
tables immediately related to your tenants, since rows in tables further out are related to rows which are
related to tenants. There can be good reasons to add the tenant id field where it's not strictly needed, such as
avoiding poorly-performing joins.
The shared-tables approach is by far the simplest and lightest in terms of infrastructure. You don't have to
worry about staging new data storage for new tenants, and you don't have to juggle connections to query
data for tenant32 A instead of tenant B: just 2ensure you're filtering for the correct
15 tenant id. You may not even
need that management layer
https://dev.to/jjude/what-is-a-multi-tenant-system-bpd 5/8
28/12/2020 What is a multi-tenant system? - DEV
need that management layer.
It's not all roses, though; you have to be really careful about managing your tenant ids to ensure that nobody
sees anyone else's stuff. In certain industries like health or finance, standards or regulations dictate stricter
segregation of tenant data. And everyone's data living in the same tables makes backups, restores, and
exports an all-or-nothing proposition; I had to develop a tool to let me work with discrete tenant data sets.
There's one other caveat I forgot to mention: it's difficult if you let tenants manage installations and/or
dictate the pace of upgrades they receive, which if you're not selling service licenses only you probably are.
That was the original job I built arachne for, pulling tenant data out of shared storage when they wanted to
go on-premise instead. Had I anticipated that scenario I might have done things differently on that one.
This is the golden way to do it. With DB level partitioning and Globally unique table keys you can even move
data between tenant groups in different databases. Yes a little bit advanced, but great Stuff :-).
This is actually
32 the way .net does it by default.
2 I'm surprised the original15author didn't include it.
https://dev.to/jjude/what-is-a-multi-tenant-system-bpd 6/8
28/12/2020 What is a multi-tenant system? - DEV
Good article!
Joseph Jude
A business technologist. Exploring intersection of technology and psychology to build a better tomorrow, for companies and
individuals.
Follow
LOCATION
Chandigarh, India
JOINED
15 de enero de 2017
32 2 15
https://dev.to/jjude/what-is-a-multi-tenant-system-bpd 7/8
28/12/2020 What is a multi-tenant system? - DEV
Trending on DEV
32 2 15
https://dev.to/jjude/what-is-a-multi-tenant-system-bpd 8/8