TQ
dev.com

Blog about software development

Subscribe

What is a multi-tenant database system?

03 Mar 2016 - by 'Maurits van der Schee'

Multitenancy in IT is the concept that you put your customers on shared infrastructure (as opposed to an on-premise solution). This concept is also referred to as "cloud computing". It may be obvious that multitenancy impacts costs, security, availability and performance. This is also true when multitenancy is applied to database systems. But note that database multitenancy is not a black-or-white thing.

5 levels of database multitenancy

You can identify the following 5 different levels of multitenancy in the database world. Customers may share:

  1. The same database schema, but have their own records.
  2. The same database (catalog), but have their own schema.
  3. The same database instance, but have their own database (catalog).
  4. The same physical server, but have their own instance.
  5. The same data-center rack, but have their own server(s).

These five levels are completely different multitenancy approaches. Option 1 ("same schema different records") is often chosen for very high amounts of customers with little data. Typically this is what business-to-consumer Internet startups are after. The advantage is that you can add a new customer instantly and it is easy to aggregate data for all customers (for instance for management dashboard).

Options 2 to 5 are chosen when there are less customers that have more data and/or higher usage requirements. Higher usage requirements may for instance be write-heavy usage with guaranteed performance or high security and availability.

Automate everything!

Automation is needed in either case. Not only to save money on manual labor, but also to ensure consistency. The closer you get to option 5 in the list above, the harder it gets to meet these two goals. But even with physical servers it is possible as some hosting companies (like LeaseWeb) already offer a bare metal API and you may script your entire infrastructure in a tool like Ansible.

What got me thinking about this

On Github you find my PHP-CRUD-API project. A project that aims to provide a high performance, consistent data API over REST that is easy to deploy (it is a single PHP file!) and requires minimal configuration. This script supports multitenancy (option 3) for a while now and I recently added support for option 1. That's what got me thinking. Anyway, check it out, it's free software!

Further reading


PS: Liked this article? Please share it on Facebook, Twitter or LinkedIn.