Users moving to Windows Azure Web Sites (WAWS) is increasing day by day. Happy to see many of the PHP websites being hosted with WAWS. If you are hosting your high traffic website with WAWS, I would like you to consider increasing the queueLength property of FastCGI handler for PHP that handles your request. By default, the value for queueLength property is 1000, which means only 1000 concurrent requests can be in the queue getting processed. For a many high traffic websites, this might seem to be a low number, and you would start seeing 503 errors in your instance logs.
With help from David Ebbo from the WAWS Product Team here at Microsoft, I was able to tweak this number with the below steps.
Steps to increase FastCGI PHP on Windows Azure Web Sites
1. Create a file named applicationhost.xdt under /SiteExtensions/<YourFolder>
Login to your website root using FTP, and create a folder /SiteExtensions. Create another folder inside it with some name, in this case, you can name it PHPQueueLength. This name is not important. Now, create a file inside that folder named applicationHost.xdt, and the content of the file is below. This specifically looks for the version PHP 5.4. If you are using a different version, then please change it to the appropriate path. Take help from the steps mentioned in this page that will let you download the copy of applicationHost.config.
<application xdt:Locator="Match(fullPath)" xdt:Transform="SetAttributes(queueLength)" fullPath="D:\Program Files (x86)\PHP\v5.4\php-cgi.exe" queueLength="5000">
2. Create an App Setting called WEBSITE_PRIVATE_EXTENSIONS for the website, with a value 1.
Login to your Azure Management portal. You can find the App Settings for your website under the ‘CONFIGURE’ tab of your website. Add a new configuration setting with name WEBSITE_PRIVATE_EXTENSIONS and value 1.
3. Restart the site from your management portal.
You can verify if this transform is applied. You could follow the steps mentioned in this page, under the ‘Debugging private Extensions’ section. This configuration will definitely help you getting rid of those server errors which are of 503s for PHP processing. However, you should still work on to see if there are any requests taking more time to get processed, and debug the same.
Here are a few blog articles which can help you to debug slow running PHP pages in WAWS, if you aren’t aware of them already.
Happy hosting with WAWS!