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.