Very High CPU usage!

Jun 17, 2009 at 6:14 PM

Hi!
Im running "IonicIsapiRewriter-1.2.15-bin" on a Windows 2003 Server with IIS V6.0.
I've set Rewrite rules for one website. However when i restart the IIS the CPU jumps to 100% usage!

This is my IsapiRewrite4.ini:
**********************************************************************************************************
**********************************************************************************************************
# IsapiRewrite4.ini
#
# sample ini file for the ISAPI rewriter.
#
# comment lines begin with #
#
# These are the currently  supported directives for the ini file:
#
#  IterationLimit
#  MaxMatchCount 
#  RewriteRule
#  RewriteLog 
#  RewriteLogLevel
#  RewriteCond
#
#
# Check the examples below for how to use each one.
# See the Readme.txt for full explanation of the rules here.
#
#
# Wed, 07 Sep 2005  09:01



#
# The set of rewrite rules in this file is partially for illustration, and
# partially for filtering ad requests.  I also have a hosts file that
# redirects known ad servers to my local machine, as per
# http://www.mvps.org/winhelp2002/hosts.htm .
#
# This rewrite rule file redirects the ad requests to the local machine, to a
# "filtered.htm" file.  You drop the "filtered.htm"  into c:\inetsrv\wwwroot and
# you can put anything you like into the filtered.htm  file.  It will display for
# every filtered ad.
#
# Wed, 13 Apr 2005  09:54
# RewriteLog  D:\inetpub\vhosts\MyDomain.com\Reglas\iirfLog.out
# RewriteLogLevel 1

# MaxMatchCount
#
# Specifies the maximum number of sub-expression matches to
# capture for a single pattern. This specifies the size of the
# array in the C module.  If you have a pattern with more than
# the default number of matches, set this number.
#
# The default is 10.
MaxMatchCount 10


# Sample RewriteRules
#
RewriteRule ^/control/admin/img/(.*)$               /control/cpimg/$1
RewriteRule ^(/.*)+/Actions.aspx$      /Actions.aspx$2
RedirectRule ^(/.*)+/HTML/(.*)$            http://www.MyDomain.com/HTML/$2
RedirectRule ^(/.*)+/css/(.*)$            http://www.MyDomain.com/css/$2
RedirectRule ^(/.*)+/img/(.*)$            http://www.MyDomain.com/img/$2
RedirectRule ^(/.*)+/swf/(.*)$            http://www.MyDomain.com/swf/$2
RedirectRule ^(/.*)+/Scripts/(.*)$        http://www.MyDomain.com/Scripts/$2
RewriteRule ^/index.html$        /Default.aspx?$
RewriteRule ^/contents/([^/]*)/([^/]*)(/.*)*$                       /Default.aspx?template=$1&Id=$2
RewriteRule ^/content/([^/]*)/([^/]*)(/.*)*$                       /Default.aspx?template=$1&Id=$2
**********************************************************************************************************
**********************************************************************************************************


Nothings appears to be wrong in the Rules. In fact, i've try them in a different eviroment and the problems doesnt appears!
I've change the RewriteLogLevel to 5 and here is the output:
**********************************************************************************************************
**********************************************************************************************************
--------------------------------------------
Fri Jun 12 16:02:29 -  5904 - ReadConfig: setting LogLevel to 5
Fri Jun 12 16:02:29 -  5904 - ReadConfig: line 50: MaxMatchCount 10
Fri Jun 12 16:02:29 -  5904 - ReadConfig: line  57: RewriteRule (rule 1)  '^/control/admin/img/(.*)$'  '/control/cpimg/$1'   (null)
Fri Jun 12 16:02:29 -  5904 - ReadConfig: not a duplicate rule...
Fri Jun 12 16:02:29 -  5904 - ReadConfig: line  58: RewriteRule (rule 2)  '^(/.*)+/Actions.aspx$'  '/Actions.aspx$2'   (null)
Fri Jun 12 16:02:29 -  5904 - ReadConfig: not a duplicate rule...
Fri Jun 12 16:02:29 -  5904 - ReadConfig: line  60: RedirectRule (rule 3)  '^(/.*)+/HTML/(.*)$'  'http://www.MyDomain.com/HTML/$2'   (null)
Fri Jun 12 16:02:29 -  5904 - ReadConfig: not a duplicate rule...
Fri Jun 12 16:02:29 -  5904 - ReadConfig: line  61: RedirectRule (rule 4)  '^(/.*)+/css/(.*)$'  'http://www.MyDomain.com/css/$2'   (null)
Fri Jun 12 16:02:29 -  5904 - ReadConfig: not a duplicate rule...
Fri Jun 12 16:02:29 -  5904 - ReadConfig: line  62: RedirectRule (rule 5)  '^(/.*)+/img/(.*)$'  'http://www.MyDomain.com/img/$2'   (null)
Fri Jun 12 16:02:29 -  5904 - ReadConfig: not a duplicate rule...
Fri Jun 12 16:02:29 -  5904 - ReadConfig: line  63: RedirectRule (rule 6)  '^(/.*)+/swf/(.*)$'  'http://www.MyDomain.com/swf/$2'   (null)
Fri Jun 12 16:02:29 -  5904 - ReadConfig: not a duplicate rule...
Fri Jun 12 16:02:29 -  5904 - ReadConfig: line  64: RedirectRule (rule 7)  '^(/.*)+/Scripts/(.*)$'  'http://www.MyDomain.com/Scripts/$2'   (null)
Fri Jun 12 16:02:29 -  5904 - ReadConfig: not a duplicate rule...
Fri Jun 12 16:02:29 -  5904 - ReadConfig: line  65: RewriteRule (rule 8)  '^/index.html$'  '/Default.aspx?$'   (null)
Fri Jun 12 16:02:29 -  5904 - ReadConfig: not a duplicate rule...
Fri Jun 12 16:02:29 -  5904 - ReadConfig: line  67: RewriteRule (rule 9)  '^/contents/([^/]*)/([^/]*)(/.*)*$'  '/Default.aspx?template=$1&Id=$2'   (null)
Fri Jun 12 16:02:29 -  5904 - ReadConfig: not a duplicate rule...
Fri Jun 12 16:02:29 -  5904 - ReadConfig: line  68: RewriteRule (rule 10)  '^/content/([^/]*)/([^/]*)(/.*)*$'  '/Default.aspx?template=$1&Id=$2'   (null)
Fri Jun 12 16:02:29 -  5904 - ReadConfig: not a duplicate rule...
Fri Jun 12 16:02:29 -  5904 - ReadConfig: Done reading, found 10 rules (0 errors, 1 warnings) on 69 lines

--------------------------------------------
Fri Jun 12 16:02:29 -  5904 - Initialize: Ionic ISAPI Rewriting Filter (IIRF) v1.2.15 final R3
Fri Jun 12 16:02:29 -  5904 - Initialize: config file 'D:\inetpub\vhosts\MyDomain.com\IsapiRewrite4.ini'
Fri Jun 12 16:02:29 -  5904 - Initialize: File watcher thread created.
Fri Jun 12 16:02:29 -  5904 - GetFilterVersion
Fri Jun 12 16:02:29 -  5752 - FileChangeWatcher(): Enter
Fri Jun 12 16:02:29 -  5752 - FileChangeWatcher: Await()...
Fri Jun 12 16:02:29 -  5752 - AwaitIniChangeAndReinit()...
Fri Jun 12 16:02:29 -  5752 - AwaitIniChangeAndReinit: no changes found.
Fri Jun 12 16:02:29 -  5752 - FileChangeWatcher(): Await returns (TerminateWatch= FALSE)
Fri Jun 12 16:02:29 -  5752 - FileChangeWatcher: Await()...
Fri Jun 12 16:02:29 -  5752 - AwaitIniChangeAndReinit()...
Fri Jun 12 16:02:29 -  5752 - AwaitIniChangeAndReinit: no changes found.
Fri Jun 12 16:02:29 -  5752 - FileChangeWatcher(): Await returns (TerminateWatch= FALSE)
Fri Jun 12 16:02:29 -  5752 - FileChangeWatcher: Await()...
Fri Jun 12 16:02:29 -  5752 - AwaitIniChangeAndReinit()...
Fri Jun 12 16:02:29 -  5752 - AwaitIniChangeAndReinit: no changes found.
Fri Jun 12 16:02:29 -  5752 - FileChangeWatcher(): Await returns (TerminateWatch= FALSE)
Fri Jun 12 16:02:29 -  5752 - FileChangeWatcher: Await()...
Fri Jun 12 16:02:29 -  5752 - AwaitIniChangeAndReinit()...
Fri Jun 12 16:02:29 -  5752 - AwaitIniChangeAndReinit: no changes found.
Fri Jun 12 16:02:29 -  5752 - FileChangeWatcher(): Await returns (TerminateWatch= FALSE)
Fri Jun 12 16:02:29 -  5752 - FileChangeWatcher: Await()...
Fri Jun 12 16:02:29 -  5752 - AwaitIniChangeAndReinit()...
Fri Jun 12 16:02:29 -  5752 - AwaitIniChangeAndReinit: no changes found.
..........
..........
.......... Those 4 lines repeated thousands times in less than 5 seconds!!!
..........
..........

**********************************************************************************************************
**********************************************************************************************************


As you can imagine the LOG was gigant, in less than 10 seconds the size was arround 50 MBs!!!
Obviously there is a serious problem with my rules, can someone help me please?

Thanks in advance!
Bye.


PD: Sorry for my poor English.

Coordinator
Jun 25, 2009 at 5:47 PM

Where have you stored the INI file?    Is it in the same directory as the log file? 

The problem comes in with the logic that checks for ini file changes.  In Windows the API to monitor a file for changes actually monitors an entire directory.  This is what IIRF uses, and it gets notified if any file in the directory changes.  Then IIRF checks to see if it is the ini file that was updated.  If not, it merely logs a message and waits again.  But the log message actually updates a file, which leads to notification of IIRF, and so on, and so on. 

If your LogLevel is non-zero, then IIRF writes a log message every time it sees a change in the directory

This is a bug in IIRF, a flaw in the design.  It can be fixed, and I will open a workitem for it.  but there is a workaround for you:  Move the ini file to a directory that does not get tons of updates.  Specifically, move it outside the IIS doc root , and to a directory different from the one you use for log files.

 

Coordinator
Jun 25, 2009 at 5:50 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.