Plenty of fun the last couple of weeks with URL Rewrite. We’ve started using rewrite rules more in the past couple of months, and seen memory use go up. Like it’s eating it. w3wp.exe was getting to 3GB, and eventually exceeding 32 bit space. We adjusted IIS so the app pool recycled at 10 hours, or if the app pool private bytes size reached 2GB. Decent workaround, but we’re leaking memory like never before.
Conversations with an IIS engineer and a fair amount of tracing of the memory image and the processes led us to URL rewrite as the culprit.
Microsoft is not versioning very well with URL rewrite. The 1.1 you have may not be the latest 1.1! We found that 1.1 was actually 7.x and that we needed to “upgrade” to a later 1.1. Same thing though, memory leak. Version 2.0, an RC, was the next recommendation.
We found that uninstalling 1.1 removed all server level rewrite rules from applicationHost.config – fun! We always have a backup of that file though. You also need to reboot if you uninstall 1.1. Upgrading to 2.0 and restoring a previously working applicationHost.config breaks your server. 1.1 server level rules are incompatible – IIS7 complains about addservervariables not having a section. Whatever. I recreated the rules in the 2.0 interface from another server in the farm. Really wish MS had documented this difficulty, or at least warned that upgrading to 2.0 nukes your global rules.
Last, but not least, we learned also that server level rules actually run in every w3wp.exe process. At the time of this writing, we see that memory usage is much better with URL Rewrite 2.0. The folks on the URL Rewrite team seemed to acknowledge that memory leaks have been a problem for the module, and that itself meant that we were going to have to look at rolling out an upgrade across all production machines. Being able to copy out applicationHost.config to each server in a load balance pool is essential in this case. I don’t even want to think about doing hundreds of rewrite rules that are running on 1.1 and putting them onto 2.0. Not yet anyway.
So: rewrite.dll, in C:\Windows\System32\inetsrv
Release 1.1 : Product Version 7.1.470.0 from April 15, 2009 – size 137KB
Release Candidate 2.0: Product Version 7.1.659.0 from November 4, 2009 – size 377KB