Nadav Hury
Nadav Hury

Reputation: 689

Finding best approach to SaaS with multiple databases, a shared resource, and EF

First please excuse me for my grammar mistakes.

Ok, this is what I already know :-), I want to use EF and MVC 4, UI with angularJs, I need a Database per user \ group of users, my application growth may come to 5000+ users, they all have also a shared resource which is a single database, when the user search for something the results will come both from the shared resource and from the user own database. Performance is extremely important.

In my research I found that EF can connect to different databases but i couldn't find any proper way of doing so without writing tons of code. Scenarios :

  1. New user registers, the system builds a new database for him.
  2. New user logs in, the system returns data from his database and the shared database.
  3. New user logs in, BUT, the system database got upgraded, users db should too.

Now I know that there is no easy method to achieve all of my goals, but can you please direct me to what suits me best?

Again sorry for my English! Thank you! :-)

Upvotes: 1

Views: 860

Answers (1)

Saravanan
Saravanan

Reputation: 7854

IMHO, we have worked in several SaaS Applications that have been using a shared database [central repository] that will contain all the user [tenant] data and that there will be an application database [tenant based] for every user group.

This will work with ease in EF and there will be no performance overheads. You should not be using cross database queries and instead focus on the optimization of the EF code that you may have in the data access layer and then you can have separate services that will handle the task of merging the user data from the shared and separate databases.

May be you should analyze the application and then find the data that may be non-frequently updated and cache them and get them rendered using a distributed cache like Appfabric.

With respect to the synchronization of the User db and the centralized database, in the service tier, you can get this job done by wrapping these calls in a .Net Transaction scope and then the preserve the atomicity.

Please post your understanding and any further clarifications in my reply.

Upvotes: 2

Related Questions