Possibly very technical question RRS feed

  • Question

  • User463357442 posted

    We are working on a new IIS related product and have faced one technical problem that I cannot resolve gracefully.
    Our product is a global (or site level) ISAPI filter and it have to be IIS 5, 6 and 7 compatible. It has a distributed text based configuration, which is stored in the site directory structure, same as in Apache or IIS7. And the problem that it have to track changes in all these configuration files in real time.
    Our previous product has only one configuration file for a web site and it was possible to check the file with GetFileAttributesEx API on every request or so. But now it is a subtree with generally unknown deep and it will be too much of overhead to check it that way. We have checked how Apache is doing it and it is trying to access every file in the subtree on every request. Possibly one of the reasons why it is so slow ;)
    Now we run a dedicated thread to watch configuration changes using a ReadDirectoryChangesW API. We put a time delay into the thread to overcome the problem of possible infinite loop or too high load. But the problem is the number of directories possible to witch with ReadDirectoryChangesW function is very limited. This is quite sufficient for a small web srevers, but for hosting providers with thousands of web sites per server this solution cannot be used. Number of possible file handlers will be spent very quickly.
    This is most likely the question to the IIS development team: How did you guys have resolved this problem with IIS 7 distributed configurations?
    Monday, March 26, 2007 5:56 AM

All replies

  • User511787461 posted

    Are the directories for the web-sites located on the IIS machine or on a unc share?  If located locally, doing one ReadDirectoryChangesW per site should not be an issue - if on unc, doing that will be an issue and you will soon run out of smb commands etc - so, checking FileAttributes is the only way to go, one thing you can do to improve performance in this case is to not check attributes if it has been checked recently enough - whatever an acceptable delay in processing changes in config may be.

    Friday, March 30, 2007 1:14 PM
  • User463357442 posted
    We are not going to offer a feature to place configuration files on UNC drives and this is not going to be higly required feature. But configuration files actually will be possible to store in every directory on the every site, just as IIS 7 is doing it, so there could be far more than one configuration file per web site.
    Checking files with a delay will not give any effect for a big servers with a large number of configuration files.
    I see only two possible ways - global API hook for writing operations and ReadDirectoryChangesW. I am almost certain that IIS 7 uses some variants of asyncronous ReadDirectoryChangesW call. We will make few more experiments, I think we are close to the correct solution.
    Thanks for the help.
    Friday, March 30, 2007 4:11 PM