September 15, 2008 at 9:44 am
Hi All,
I have recently been tasked with looking at migrating our product to SaaS, and the pheasability of hosting Multi Tenancy databases.
I have read up quite a bit on this, and have had the following thoughts towards a possible solution:
Use a single database to hold all customers data.
Use with shared tables with partitioning (creating a tenant id field); or create tables within a schema for each customer. (I would still possibly use schemas for the shared tables, by creating dbo tables and then schema views to ensure that customers only see their own data).
My question is, does anyone have experience of implemeting multi tenancy in the real world, and if so, do they have any comments on my proposed options?
Many thanks
September 15, 2008 at 10:06 am
I've avoided this because at some point I've needed to separate customers out. Either scale/size issues or regulatory problems.
I usually go with a separate database for each customer.
September 15, 2008 at 1:31 pm
Separate databases. Lots of reasons.
Makes it easy to split it up onto separate servers to scale out.
When a customer calls you and wants you to restore "their" database to "last night, before we accidentally deleted all of our records", it's a lot easier to do that if you don't have to worry about overwriting other customers' data.
More secure.
Legal compliance in some cases.
Easier to retire a database if you lose a customer than it is to clean all of their data out of a multi-tenant database.
You can offer more by way of customization, since table alterations don't break what other customers are doing.
Disaster recovery: If one database file gets corrupted, and you only have one database, you're in a lot more trouble than if one database file gets corrupted and you have one database per customer.
And so on.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
September 15, 2008 at 1:35 pm
Two things to add to that:
If you decide to go one-per-customer, make sure to set up your model database (system databases) so that it's got everything a new customer needs. Then, when you create a new database, it's ready to get started.
Second, create a "Common" or "Shared" database with static data that all the databases will need access to. Things like tables of US states, Zip codes, a Numbers table, possibly a basic calendar table. That way, you don't have to store that data dozens of times for dozens of customers. But make sure it's ONLY for common data that everyone needs access to, and make sure it's in read-only mode to simplify locks.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
September 16, 2008 at 1:24 am
Many thanks for your replies. Lots of good advice. Never thought about restoring for different customers!!
September 16, 2008 at 3:06 am
Rootman (9/15/2008)
My question is, does anyone have experience of implemeting multi tenancy in the real world, and if so, do they have any comments on my proposed options?
Yes, I did it using Oracle VPD which is designed specifically for that purpose.
My comment... I wouldn't do it again, in the Oracle world I would go with a private schema per "customer", on the SQL Server world I would go with a private database per "customer".
_____________________________________
Pablo (Paul) Berzukov
Author of Understanding Database Administration available at Amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply