Monday, October 10, 2005
Using the HTTP.SYS Kernel Mode Cache from ASP.NET
first question of course will be "what is the difference between Kernel mode and user mode ?" .
kernel mode is the OS mode .it is by default a 2GB piece of memory. it is a protected area .running under elevated privilages(Local System) . so anything running in kernel mode is actually very very fast over user mode coz they have elevated priority over anything running in User mode .
by default User mode is 2GB peice of memory. it is the place to run all the applications ( including IIS) in windows OS
so one of the implications of implementing a kernel mode http listener is dramatically increase the performance .
let's have a look on caching in ASP.NET Today , I could take the data i need to cache and basically store it in memory and guarantee that on subsequent requests, IIS is going to call ASP.NET; ASP.NET is going to get the choice to say, based on the URL you're asking for, I'm going to fetch this out of memory if I have it; and then I can send a response back down. But with IIS 6.0, the extra benefit you get is that rather than IIS ever having even talked to us, the request can be pushed in IIS and it can be served straight from IIS.
so caching data in kernel mode (HTTP.SYS) avoids context switches between user mode and kernel mode .it is dramatically increasing performance , and when talking about performance we can measure this with a very simple page built with ASP.NET on MS Application Center . the difference between no of req/sec before and after apply caching is incredible
note: to apply HTTP.SYS caching from ASP.NET you have to add the @OutPutCache Directive to the page