Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Azure slow on first few requests

Tags:

azure

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?

like image 680
97ldave Avatar asked Mar 18 '13 15:03

97ldave


3 Answers

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.

like image 158
mattytommo Avatar answered Nov 18 '22 20:11

mattytommo


Are you precompiling the application? By default, the application after being deployed still needs to be compiled for the first time. Depending on the size of the application, compile can take multiple seconds http://msdn.microsoft.com/en-us/library/399f057w(v=vs.85).aspx

like image 31
Igorek Avatar answered Nov 18 '22 19:11

Igorek


When the first HTTP request arrives a lot of extra work is actually done - application pool is started, all needed assemblies are found, all assemblies shipped as MSIL are compiled into machine code, then the necessary ASP.NET views are precompiled (unless you deploy them precompiled, but it's quite hard with Azure tools so I guess you don't do that). This all takes some time and so the unlucky first users have to wait.

The workaround is to warm up the site from inside role entry point OnStart() - make it precompile the site and then send an HTTP request to localhost.

like image 34
sharptooth Avatar answered Nov 18 '22 19:11

sharptooth