Lessons in this course (9)

9. Web farms, deployment automation and performance tuning

AdvancedMediumLesson 9 of 9

Web farm (multiple IIS servers):

  • Load balancer in front (hardware, Azure Load Balancer/Application Gateway, or ARR).
  • Same code and config on every node — deploy with Web Deploy, Azure DevOps or IIS Shared Configuration + DFS-replicated content.
  • Machine key (ASP.NET Framework: <machineKey> for ViewState/Forms auth) or Data Protection keys (ASP.NET Core: shared folder/Redis/Blob) must be identical across nodes.
  • Session out-of-process (SQL Server/Redis) or sticky sessions.

Deployment automation:

powershell
# Web Deploy (msdeploy) from a build agent
msdeploy.exe -verb:sync -source:contentPath="C:\build\publish" -dest:contentPath="Shop",computerName="https://web01:8172/msdeploy.axd",userName="deploy",password="***",authType="Basic" -enableRule:AppOffline -allowUntrusted

Azure DevOps: deployment group/agent on the server + "IIS Web App Manage" and "IIS Web App Deploy" tasks; GitHub Actions: self-hosted runner + PowerShell.

Performance tuning: AlwaysRunning + Application Initialization (warm-up), disable idle timeout for busy apps, schedule recycling at off-peak times, enable compression and static caching, HTTP/2 (and HTTP/3 on Server 2022+), check queue length and Requests/Sec counters, avoid web gardens for stateful apps, use async code to avoid thread-pool starvation, keep debug="false".