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.
You can identify the following 5 different levels of multitenancy in the database world. Customers may share:
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.
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.
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!