Windows Azure slow on first few requests

azure

Solution

I have looked at this: Controlling Application Pool Idle Timeouts in Windows Azure, but not sure if this will still cause an issue when Azure recycles the application pool every 29 hours approx.

It won't cause an issue when Azure recycles the app pool, but you can also add to that startup task to prevent/increase the application pool recycling time.

Try this:

Define the task in your `ServiceDefinition`:

<Startup>
    <Task commandLine="startup\disableTimeout.cmd" executionContext="elevated" />
</Startup>

Then have your `cmd` file with the following code (just put it into notepad, then save as a `.cmd` file):

%windir%\system32\inetsrv\appcmd set config -section:applicationPools -applicationPoolDefaults.processModel.idleTimeout:00:00:00

%windir%\system32\inetsrv\appcmd set config -section:applicationPools -applicationPoolDefaults.recycling.periodicRestart.time:00:00:00

Two things to make sure of:

1) Make sure you save the file with ANSI encoding. 2) When you've added that script into Visual Studio, make sure you select "Copy Always" as the "Copy to Output Directory" option in the properties.

Problem

When the website is accessed by the first few users the performance is very slow. The Windows Azure setup is using IIS 7.0 so the warm up initialization module is not an option. Is there a way to "warm up" the website so that this performance speed is not an issue? I have looked at this: Controlling Application Pool Idle Timeouts in Windows Azure, but not sure if this will still cause an issue when Azure recycles the application pool every 29 hours approx. UPDATE: The deployment is 1 web role that contains multiple websites. Is it possible to do the pre-compilation for this? or use web roles as is suggested in one of the answers below? EDIT: As @Igorek has stated below regarding using Web Roles that auto-load themselves during Role's startup which is possible in the setup I have. Does anybody have an example of how to achieve this?

Original source