Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

one database per client or all clients in one database. which one should I use for a online application?

So I have this application that would have multiple modules, from project management to accounting modules. The question is should I have one database per client (company) or one database that holds everything ?

1) which one would be better performance wise?
2) is is going to be a lot harder to manage multiple databases or is these manageable.
3) We are going to have the same application for all users, meaning that the same schema is going to be used no matter the number of databases.
4) some clients are going to have a lot of that (accountants for example might have up to 2 million row added per year in one table) while others are going to use much much fewer data.

what do you think I should use?

like image 940
redmoon7777 Avatar asked Jan 02 '12 19:01

redmoon7777


People also ask

Should each customer have their own database?

Having a separate database per customer also provides a smaller surface area when it comes to security. Different credentials can be used per customers' data, and auditing of logins or access to customer data is made simpler.

Should I have a separate database server?

In some cases, upgrading to a server with more resources can be the best way to ensure operations continue smoothly. In other cases, the best and most cost-effective way to maintain system reliability and performance is to split off resources to run your database from a separate server.


1 Answers

1) Having separate databases allows for easier distribution of load on several hosts, it lifts the roof in many ways; disk, memory, locking, cpu, backup-time and so on. If you are serious about putting millions of rows in mysql, it is certainly a good idea with separate databases (not only schemas), and even separate instances, so that the resource-consuming customers won't impose downtime on less resource consuming ones.

2) It is going to be exactly N times harder to manage where N is the number of databases :o) This extra cost you must compare to the cost of using just one db/schema and instead manage separation of customer in code. It's also inherently much harder to manage if you have to call customer support at your hosting company, or even your local grumpy dba, instead of just running a neat script from your console each time you need to update schema or create a new database.

Some databases and persistence frameworks have support for multi-tenancy, Oracle has this and support is beginning to emerge in Hibernate 4.

Even though many arguments point in the direction of separate databases, it is generally possible to use just one database as well.

like image 91
Jon Martin Solaas Avatar answered Nov 15 '22 11:11

Jon Martin Solaas