What are the best practices in building applications that support multiple tenants such as Software as a Service?
Links to white papers that expand on this topic are greatly appreciated.
The primary concern is how to ensure that proper security and isolation protects consumers or tenants of these services from the risks they pose to one another.
In a multi-tenant architecture, multiple instances of an application operate in a shared environment. This architecture is able to work because each tenant is integrated physically, but logically separated; meaning that a single instance of the software will run on one server and then serve multiple tenants.
For the database:
A. Put everything on the same database, put a tenant_id column on your tables
Pros: Easy to do
Cons: Very prone to bugs: it's easy to leak data from one tenant to another.
B. Put everything on the same database, but put each tenant in its own namespace (postgresql calls them schemas)
Pros: Provides better data leak protection than option A
Cons: Not supported by all databases. AFAIK PostgreSQL and Oracle supports it.
C. Setup one database per tenant
Pros: Absolutely no chance of data leaking from one tenant to another
Cons: Setting up new tenants is more complicated. Database connections are expensive.
I only learned the above ideas from Guy Naor. Here's a link to his presentation: http://aac2009.confreaks.com/06-feb-2009-14-30-writing-multi-tenant-applications-in-rails-guy-naor.html
You might find some valuable advise in a series of blog posts by Oren Eini.
This is one of the last posts in the series, with links to previous posts: http://ayende.com/Blog/archive/2008/08/16/Multi-Tenancy--Approaches-and-Applicability.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With