If you are experiencing that cloud service web roles are slow for the first call or request, this is due to the default IIS Application Pool setting is set to recycle after 20 minutes.
This means, that every 20 minutes of inactivity, the application pool will recycle which means any request after this period will experience slow load time that you need to avoid for your customers.
If you have Azure Web Application (websites), you can easily configure this by turning on Always On switch in Azure Management Portal under Configure tab and you will be able to get your site faster to load!
Unfortunately, this option is not available for cloud service web roles, To achieve the same you need to follow these steps:
1) In your web application, add a new folder and name it: Startup
2) In the Startup folder, right click and add a new Text File in VS 2013.
3) Name the new file: Startup.cmd
4) Paste the following command in the Startup.cmd file (as one line) :
if exist %windir%\system32\inetsrv\appcmd.exe %windir%\system32\inetsrv\appcmd set config -section:applicationPools -applicationPoolDefaults.processModel.idleTimeout:00:00:00
This command sets the IIS recycle app pool setting to zero which is never recycle!
Make sure to test out the cmd file by running it form the command prompt as admin, the output of the command should look like this below figure.
5) Select the Startup.cmd file in VS 2013 and press F4 to change the file properties.
6) Set Copy To Output Directory to Always Copy.
7) Save you changes and build your website, make sure that you have startup folder in the bin folder.
8) Publish your cloud service and check the difference for the first time you call the site after the deployment!
Hope this helps!
Post a Comment