views:

444

answers:

2

Background Info: File Replication is Lame

Currently, we have a massive, high-traffic ASP.NET web application load-balanced across 8 different IIS servers. Due to the nature of the site, minor changes to .aspx files and .ascx controls happen frequently throughout the day, and after being tested and published to live, are replicated out to each of the public webservers through xcopy deployment on a scheduled basis every 10 minutes.

Of course this is incredibly inefficient, as each server must have a redundant copy of the entire site, and we would like to eliminate the 10-minute publishing lag.

Possible Improvement: Hosting from Shared Storage

We now have the option to use centralized storage with an iSCSI interface to host the entire site centrally, with each server believing that the remote storage is a local drive. Publishes would be instantaneous and system-wide.

Note: Hosting the drive off a UNC share is not possible, as there are so many different directories in the site structure, each requiring a FileSystemWatcher for ASP.NET to monitor for changes, that the SMB maximum command count is quickly reached. Yes, we know about the MaxCmds and MaxMpxCt registry settings.

The Problem: Web.config changes trigger massive recompiles

The problem we forsee is that certain changes to the file system structure can cause nearly every compiled .aspx or .ascx to have to recompile, causing queued requests and a perception that the server is down. Most resources are not used system-wide and so recompiling them on a change causes hardly a blip in resources. A global master page used by all pages on the site can cause this, but this can easily be managed by code.

The primary culprit is the web.config file. Changes to the web.config file cause the entire web application to recycle, and recompilations to occur. So, we currently don't replicate web.config changes. Any web.config changes requires bringing the web server off the load balancer, applying (and testing) the changes, and then warming the server up with junk requests before it is placed back on the load balancer.

However, if the web.config file, like the rest of the web application's directory structure, is located on centralized storage, there is only one copy of the file, and individual servers could not be patched and warmed up anymore.

The Question

Is there a way to get an ASP.NET web application to take its marching orders from a source other than a file named Web.config?

Ideally there would be one file per server, for example:

  • default.aspx
  • global.asax
  • Web-ServerA.config
  • Web-ServerB.config
  • ...
  • Web-ServerN.config

Where is the name "web.config" defined anyway? Is there a registry setting that could be set on a per-server basis? Is there an entry that could be made in the machine.config or the global web.config to specify what file to use?

Things Out Of Scope

Just so I am clear, I am not asking how to have different AppSettings for debug, test, and live. There are other topics that cover this, and all my web.configs will be identical most of the time, the only time I need them to be different is when an update is being performed.

We aren't using the web.config for any appSettings information; this is for the really important stuff, like assembly references, httpHandler definitions, and other system.web settings that can not be databased.

Update

I tried searching the registry for Web.config, and found nothing except for applications that noted that I had recently edited web.config files, which I apparently do a lot. No help there.

+1  A: 

My first question would be what are you keeping in the web.config & can you move it to a database? We keep every config setting in a table in our database and use the machine.config to store the db connection information.

Not sure how much of a rewrite that would be for you, but it would avoid your issue.

Another option would be to house your configuration items in an external file and reference it from the web.config. Changes to that file would not be re-read until the aspnet wp was recycled but would allow you to change setting and then cycle each server via an IISRESET.

<configuration>
   <appSettings file="OtherFile.config">
...
Chuck
This has nothing to do with appSettings. This is for the stuff that MUST be in the web.config file, like assembly references and httpHandler definitions.
David
Ah - thanks for updating the question.
Chuck
Web.Config has an AppSettings section, I believe this is what you need to accomplish your task. Did you overlook this? You need to use the appSettings section to address your problem. Dont re-invent the wheel.
Devtron
A: 
  1. Just curious, what filesystem are you using? NTFS is not a shared storage file system. In other words you can't have more than one node writing to the filesystem at a time.

  2. I would suggest virtual directories under the site in IIS. This will probably require a little bit of restructuring the layout of your code, but shouldn't be too major. So, you would have the root home dir of the site with the web.config that is specific to that machine and then a vdir mapped to whatever shared filesystem resource you setup.

rorr
While not a perfect solution, there may not actually be one, so I'm marking this as the answer. Especially if most frequently-updated content can be relegated to a specific virtual directory, some replication of the root, seldom-changing content would be acceptable.
David