re:
!> when the code to do this is deployed in IIS the code it takes about 16
!> seconds while under asp.net development server (built in visual studio
!> 2008 web server) it takes 2 seconds. I have determined this using
!> trace.axd with custom messages that I have written at various stages
!> of this process. Why is there such a big difference in the times?
How isolated is your application in the IIS Server ?
In the ASP.NET Development Server, your app can use up to 100% of the CPU time.
In the IIS Server :
1. Is the app running in its own Application Pool ?
If the app is sharing the Application Pool with other applications,
that could have an impact on performance.
Simply isolating the app in its own App Pool will improve performance.
2. How many processors does the IIS Server have ?
If the application is critical enough, and you have a quad processor,
for example, you could allocate 2 processors to ASP.NET
Look up the processModel and cpuMask configuration parameters in machine.config.
ASP.NET launches one worker process for each qualified CPU.
If the webGarden attribute is configured to true,
doing this limits worker processes to the number of qualified CPUs.
The maximum for worker processes is equal to the number of CPUs.
If webGarden is false, this attribute is ignored and only one worker process will run.
This is the default behavior, which is why it needs to be configured
to be able to take advantage of your unused processing power.
Be careful when configuring the cpuMask, as it needs a hexadecimal value.
The default is "0xffffffff", which enables one processor only.
The cpuMask hexadecimal value 0x0d represents the bit pattern 1101.
On a computer with four CPUs, this indicates that ASP.NET
processes can be scheduled on CPUs 0, 2, and 3, but not on CPU 1.
Make sure you use the correct hexadecimal value desired if you're configuring the cpuMask.
Note that, if you want to use the cpuMask, you must set "Webgarden" to true.
Otherwise, the cpuMask parameters will be ignored, and Windows will schedule
cpu usage to its convenience, which means that other processes might get more
priority, instead of ASP.NET being the most prioritized Windows process.
See :
http://msdn.microsoft.com/en-us/library/5dws599a.aspx
<quote>
When an ASP.NET Web page calls an external resource, such as when performing database access requests,
the page request stops until the external resource responds, freeing the CPU to process other threads.
If another request is waiting to be processed and a thread is
free in the thread pool, the waiting request begins processing.
The result can be a high number of concurrently executing requests and many waiting threads
in the ASP.NET worker process or application pool, which hinders the Web server's throughput,
adversely affecting performance.
To work around that, you can manually set the limit on the number of threads in the process by changing
the MaxWorkerThreads and MaxIOThreads attributes in the processModel section of the machine.config file.
</quote>
Be very careful when you do this...and test each Max parameter you change, in isolation.
You might want to, initially, set the processModel to autoConfig="true".
The built-in parameters usually provide enough performance.
You did not reply to Mark when he asked you whether SQL Server
is located on the same machine as the IIS web server.
If you need more processing power, and your IIS server has 2 processors, and if SQL Server
is located on the same machine as the IIS web server, you might want to set the cpuMask
so that one processor is used by ASP.NET and the other is specialized for SQL Server.
You can set the SQL Server's processor affinity in Task Manager.
Also in Task Manager, you can increase the Priority for the ASP.NET process (w3wp.exe)for your app.
That will effectively dedicate more cpu time to ASP.NET/IIS.
The throughput gains by configuring the above suggestions are mind-boggling.
3. Have you disabled Debug mode for the application ?
IIS responds more slowly when applications are running in Debug mode.
Make sure you disable debugging for the IIS application in the app's web.config
I hope these tips help you configure your IIS web server to achieve more throughput.