Affinity Groups in Windows Azure–How Those Work?
Affinity Groups is an interesting concept that Windows Azure introduced a while ago but it seems that people are confused how it works. Here is a short explanation how you can benefit from the Affinity Groups, and things that you need to be aware of when you use them.
Benefits of Using Affinity Group
As the name suggests Affinity Groups are intended to group dependant Windows Azure services, and deploy those in one place if possible. This can have several benefits among which are:
- Performance – If your services are dependant on each other it is good if those are co-located, so that transactions between them are executed faster. The best option is if the network hops between your hosted services are minimized as much as possible
- Lowering your bill – As you may already know bandwidth within the data center is free of charge (you are still charged for transactions though). Currently it is possible to co-locate your services if you choose the same sub-region and using Affinity Group is just another way to do that
How Affinity Groups Work?
Although the Affinity Groups give you the benefits outlined above, here are few things you need to be aware of when using them:
- Specifying the same Affinity Group for two or more hosted services tells Windows Azure to optimize the deployment of those services and locate them closer to each other. Windows Azure makes best effort in this optimization
- Specifying the same Affinity Group for hosted service and storage account means that those two will be co-located in the same data center. Right now this is equivalent to selecting the same sub-region for both
In essence Affinity Groups gives you small advantage over the use of sub-regions – it instructs Windows Azure to make an effort to deploy your hosted services and optimize their location.
Note (June 22nd 2010): I’ve done some edits to this post to unify the terminology with Windows Azure one, and clarify the billing benefit:
- Initially I wrote that transactions within data center are free of charge, which is not completely true. What I meant is that bandwidth is free of charge however you are still charged for transactions
- Although I used “region” throughout the post I meant “sub-region” (for example US-North Central). In this context you should also consider “sub-region” and “data center” as interchangeable terms
- Choosing sub-region guarantees you that your service will be deployed in the selected sub-region. Choosing Affinity Group instructs Windows Azure Fabric to make a best effort to optimize the deployment of your services
Hope those clarifications are not distracting you from the main purpose of the post – to explain what the Affinity Groups can be used for.