1

My goal is to write an ASP.NET MVC application that runs once for many databases.

The idea beyond this is that I plan to have a client/server app converted to a web app, so the most traffic (and resource consumption) I expect is from the app to the database and not in the app itself (no "scientific calculations") or from app to client.

One thing I am trying to achieve is to have one server hosting the app on IIS, but underneath I would like to connect to multiple databases (postgresql databases on linux servers).

So the deployment scenario would be:

SERVER1 (Main) - Windows - hosts iis + "10" postgresql dbs

SERVER2- Linux - "20" postgresql db

SERVER3ToN- Linux - "20" postgresql db

(I write "10" and "20" just to give an idea that more dbs "could" be hosted on "idle servers")

Moreover I would like that every db is accessed from a different URL:

localhost:8080 or customer1.myapp.com makes the app work on DB1 on SERVER1

localhost:8092 or customer12.myapp.com makes the app work on DB2 on SERVER2

This of course is good when hosting the app, it is not super scalable (means once the app takes the full CPU i will need to install it one more instance on another machine, but to add 1 more db i just need to add a db in the list of supported dbs), but enough for my needs. It allows also to install on premise in case it is needed.

My question is: "is there an existing pattern for achieving this or it must be written from scratch?" Any help is welcome!

To express myself better by existing pattern I mean:

1) an existing demo app

2) a best practice written at some weblink

3) an asp.net mvc feature i am not aware of

Of course I could write it from scratch (e.g. by reading the list of supported dbs from a config file and make all the necessary arrangements) but before attempting this I would like to have a hint from the StackOverflow community.

CodeCaster
  • 147,647
  • 23
  • 218
  • 272
UnDiUdin
  • 14,924
  • 39
  • 151
  • 249
  • 1
    See for example [Using multiple databases within one application](http://stackoverflow.com/questions/2624154/), [Host Multiple Domains with the same ASP.NET MVC app?](http://stackoverflow.com/questions/685973/), [How to serve multiple domains with a single ASP.NET MVC application?](http://stackoverflow.com/questions/3271408/). You need to narrow down your question, or try at a different SE site if you want to discuss application architecture. – CodeCaster Jul 14 '14 at 13:18
  • The Web.config gives you this ability natively. Just name your connection string and then tell your context to use that connection string name. Then, just change the connection string for each server. You can even create additional configurations (besides the default of Release and Debug) and then setup transforms to automatically change the connection string depending on which configuration you're publishing with (obviously you would create one configuration per server). – Chris Pratt Jul 14 '14 at 14:17
  • Actually, didn't read your question right, but I stand by my comment. It may be the same site, but that doesn't mean you can't deploy it multiple times. If each instance uses a separate database, they're really separate apps, even if they share the same frontend. – Chris Pratt Jul 14 '14 at 14:20

0 Answers0