The importance of queues as a communication medium between Web and worker roles is a bit underestimated. Apart from acting as reliable messengers, properly implemented queues hold the key to your application being extensible and scalable.
Windows Azure Queue allows decoupling of different parts of a cloud application, enabling cloud applications to be built easily with different technologies and to scale with traffic needs.
This description is full of some very important keywords: decoupling, different technologies and scale with traffic needs. All are very important to make a scalable and extensible application.
Let's see how queues help in all these aspects.
1. Scalability
- Observing the queue length and tuning the number of back-end nodes accordingly, applications can effectively scale smoothly according to the amount of traffic. A growing queue length or queue length of almost always zero is an indication of how loaded your worker roles are, and you might want to scale them up or down accordingly.
- The use of queues decouples different parts of the application, making it easier to scale each part independently. This allows the number of web and worker roles to be adjusted without affecting the application logic.
- Separate queues can be used for work items of different priorities and/or different weights, and separate pools of back-end servers can process these different queues. In this way, the application can allocate appropriate resources (e.g. the number of servers) in each pool, efficiently using the available resources to meet the traffic needs of different characteristics.
2. Extensibility
- Different technologies and programming languages can be used to implement different parts of the system with maximum flexibility. For example, the component on one side of the queue can be written in .NET framework, and the other component can be written in Python.
3. Decoupling
- Changes within a component are transparent to the rest of the system. For example, a component can be rewritten using a totally different technology or programming language, and the system still works seamlessly without changing the other components. The old and new implementations can run on different servers at the same time, and they can process work items off the same queue. These components are transparent to the other components in the application.
But to be able to achieve these benefits, you need to make sure your queues are implemented in the most optimal way. Best practices in queue implementation include Invisibility Time, Delete queue messages, worker role instance manipulation and much more.