multi-tenant database architecture -


i building saas application , discussing 1 database per client vs shared databases. have read lot, incluisve topics here @ have still many doubts.

our plataform should highly customizable each client. (they should able have custom tables , add custom fields existing tables). multiple database aproach seems great in case.

the problem is. should "users" table in master database or in each client database?. user might have 1 or more organizations, present in multiple databases. also, generic tables countries table, etc?

it makes sense in master database. have many tables created_by field have foreign key user. have permission related tables client.

i loose power of foreign keys if multiple databases, means more queries database. know can use cross-join between databases if in same server loose scalability. (i might need have multiple database servers in future). have tought federated tables. not sure performance.

the technologies using php , symfony 2 framework , mysql database.

also, afraid maintenance of such system. create scripts automate schema changes in databases, if have 10k clients mean 10k databases.

what opiniion this? main caracteristic of app should flexibility if client needs more specific base plataform doesnt have, should possible him.

some classic problems here. have ever been http://highscalability.com/? case studies there.

from personal experience if try share clients on 1 server, find successful/active user take resources of machine on time. had 1 client in saas destroyed shared server , had move him somewhere else.

i rip out global enumerations service. can make 1 central database things list of countries, list of states, etc. , put behind web service layer. in database can have user management/managing server belongs user etc. can make management portal reads/writes database managing user base.

if doing saas again, start small , wait pain hit. want tools address scaling issues when happen. have scripts ready rolling schema changes across servers (no way avoid once have more 1 server). have scripts take down machines while modifying schema. have scripts migrate user shared server dedicated one.

consider setting replication central database. pump down global information each user partition/database need without having write lot of code.

but biggest piece of advice i've seen - , experienced first hand - don't try hard build next facebook scale. start simple , see happens before worrying major scalability issues. might surprised user base grows scales , not.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -