0

I want to implement some kind of a configuration of the same website (www.example.com) so on IIS I want to have two instances with two application pools so one instance located at:

c:\Site1

And the second one located at

c:\Site2

both sites are 100% equal with the only exception of the database connection string, each one is pointing to a different database server.

So in the DNS will be pointing to www.example.com and on IIS each instance will point to www.example.com.

I'm doing this way because I need to restore the database daily with new information so in my current scenario I have to stop the application, restore the database and then restart the application so the website goes offline every time I do this.

So I was thinking to do something this way so I can stop Site1 then restore the database then restart the site and do the same for the Site2

enb141
  • 156
  • 1
  • 1
  • 10

1 Answers1

0

Rather than duplicate the websites, you can have two databases e.g. DB1 and DB2.

If DB1 is active (configured in web.config), restore to DB2. Then, update web.config to point to DB2. Currently active requests will complete using the old configuration (pointing to DB1), but all new requests will use the new configuration (pointing to DB2).

UPDATE

Based on your heavy startup cost, you can instead create the two websites as www1.example.com and www2.example.com, and setup a third site as www.example.com that simply redirects to either www1 or www2 depending on which one is ready. You can configure the redirection within IIS, no need for an html or ASP.Net page to accomplish the redirect.

Eric J.
  • 147,927
  • 63
  • 340
  • 553
  • The problem doing this way is that my website takes a while to load because it has to read some tables and execute some tasks for caching before it starts up. – enb141 May 17 '14 at 04:41
  • Unfortunatelly my website is SEO so if I add www1 and www2 the seo will kill me because the google crawler will think I have two different websites. – enb141 May 17 '14 at 08:19
  • Why don't you handle it in code then, build some intelligence in your data access layer in the web app that can rebuild the cache from the "other" DB (the one just restored), and then once the rebuild is done, use that updated cache to handle web requests. Requires code change, but cleaner than other options like changing the website bindings every time you update the DB (also an option, but not sure how to automate that). – Eric J. May 17 '14 at 17:22
  • The problem is that every time the web.config is edited the application restars so the caching rebuilding is recalled. – enb141 May 17 '14 at 21:39
  • Don't toggle the active DB with web.config. Have 2 connection strings, and use another mechanism to set the active one (e.g. an extra file with a file watcher on it, or an admin page in the app). – Eric J. May 18 '14 at 07:01
  • That's what I was thinking to do before I came with the idea of two instances. I was planning that option but before create that one it came to my mind the two instances so I'm asking here if that's possible without making it harder to do it. If so I will not have to program the part in which chooses which database to use. – enb141 May 18 '14 at 07:04