Forgotten, often miss understood Affinity Groups are the glue between your Windows Azure services. By physically grouping Cloud and Storage services together, they contribute to the overall performance of your application by reducing network latency. Furthermore, by using them you are effectively ensuring that the Fabric Controller always tries to move your services together.
To better understand why Affinity Groups are important, imagine a building the size of several American Football fields containing hundreds of thousands of servers. Windows Azure datacenters are vast and quite complex. The Fabric Controller, responsible for allocating resources, relies on Affinity Groups to decided where to deploy your services. Without an Affinity Group, parts of your services may be deployed at opposite ends of a datacenter. Consequently, introducing unnecessary network latency between your compute and storage services.
Keeping network latencies low is particularly important when Cloud services make extensive use of Storage services.
Affinity Groups should be setup at the begging of a project in order to provide a greater degree of co-location of our services within a datacenter. Beware that moving deployed services into an Affinity Group afterwards isn’t trivial. It requires us to recreate our Cloud and Storage services. Then we need to redeploy everything to the production environments.
As of April 2013, Affinity Groups only support Windows Azure Cloud Services and Windows Azure Storage Services. No other services are able to take advantage of Affinity Groups, because they do not share the same server clusters. Therefore, other services like Windows Azure Websites, Windows Azure Mobile Services, Windows Azure Virtual Machines, Windows Azure SQL Database, Windows Azure Service Bus, Windows Azure Media Services and Windows Azure Access Control are not supported.
Creating an Affinity Group on Windows Azure
To create an Affinity Group, open the Settings area of the Management Portal, click Affinity Groups, and then click Add located at the bottom of the page to create a new Affinity Group.
You can also create and manage affinity groups using the Windows Azure Service Management API. See Operations on Affinity Groups for more information.