Performance Tips for Azure App Services

Compiled from multiple online articles:

* Configure your App Service to use HTTP/2 - It brings features like header compression and binary formatting (which reduce payload sizes), request pipelineing and multiplexing. These features allow for more concurrent requests using fewer network sockets and help to avoid one slow request from blocking all subsequent requests , which is a frequent problem in HTTP 1.1. HTTP/2 might not benefit every application, so you will want to run performance tests and stress tests to document your improvements.

* Turn Off the Application Request Routing Cookie - By default, Azure will make sure clients continue reaching the same app service instance during a session, because Azure can't guarantee your application isn't storing session state in server memory. To provide this behavior, the load balancer will inject a cookie into the first response to a client. This cookie is what Azure calls the Application Request Routing Cookie. If you have a stateless application and can allow the load balancer to distribute requests across instances without regard to previous requests, then turn off the routing cookie in the Configuration blade to improve performance and resiliency.

* Keep the App Service Always On - IIS will unload idle websites after a period of inactivity. Azure App Services will also unload idle websites. To prevent the idle shutdown which can hurt the performance of the app, you can set the Always On flag in the App Service Configuration blade.

* Use a Local Cache (by creating a new App Setting for the app with a key of  WEBSITE_LOCAL_CACHE_OPTION and a value of Always) if possible instead of using Azure Storage which is by default the file system for your App Service. This prevents your application from making a network call every time the app touches the file system.

* Co-Locate your App Service and your Database & choose the Azure region closest to your customers

* Avoid roundtrips to the database by using Azure Redis Cache

* Keep static content close to the customer by using a Content Delivery Network - Static files like script files, images, CSS files, and videos, and are all good candidates for caching on the CDN edge servers.

* Avoid latency by using Azure Traffic Manager

Comments