Implement Queue-Based Load Leveling Pattern in Azure - Part 1

Search for a command to run...

No comments yet. Be the first to comment.
Introduction : As AI agents gained more and more traction with LLM as a reasoning engine , it started to interact with more data sources with each one requiring its own custom implementation . So Anth

Introduction Pipes and Filters is one of the popular enterprise integration and cloud design patterns where in we divide a larger processing task into a sequence of smaller, independent processing steps (filters) that are connected by channels (pipes...

Introduction: In part 1, we saw the publisher-subscriber pattern in Azure, useful scenarios in which the pattern is implemented, and different approaches to implementing the pattern in azure. In this blog post, I will be implementing the pattern usin...

Introduction : Publisher-Subscriber pattern commonly called the pub-sub pattern is one of the most popular messaging paradigms where we enable applications to announce events to multiple interested consumers asynchronously, without coupling the s...

Introduction : In part 1, we saw Asynchronous Request-Reply Pattern in Azure, useful scenarios in which the pattern is implemented, and different approaches to implementing the pattern in Azure. In this blog post, I will implement the pattern using o...

Context and Problem:
Many Cloud Solutions involve running tasks that invoke services, if the service is subjected to intermittent heavy loads, we will end up in performance degradation and availability issues. This leads to tasks getting timed out or the service getting failed.
A service can be invoked by multiple tasks concurrently and it is difficult to predict the volume of requests to the services at any time. Because of this reason, services might not respond to the tasks in a timely manner and also lead to service failures due to contention issues. Task and Service are tightly coupled in this case.
Solution :
In order to overcome such issues, you need to decouple the task and service to run asynchronously and the answer for this is Queue-Based Load Leveling Pattern. Implementing this design pattern introduces a queue that acts as a buffer between the task and the service in order to smoothen the intermittent heavy loads thereby minimizing the impact of the peak in demand on the Availability and Responsiveness of the Service.

Benefits :
Issues and Considerations :
Scenario to implement this pattern :
Implementation of the Pattern in Azure in different Scenarios :
Problem :
A web app writing data to the external data store. If the number of web app instances run concurrently the data store might not respond to requests quickly enough causing requests to timeout, throttle, or otherwise getting failed.

Solution :
To resolve the above problem, we can use this queue-based load leveling pattern by introducing the messaging queue to level the load between the application instances and the data store. Azure Function App reads the messages from the queue and performs read/write to the data store. Application logic written in the function app can control the rate at which the requests are being sent to the data store to prevent the store from being overwhelmed.

Problem :
An Azure Logic app / Function app trying to invoke an API which is a downstream system directly might come across scenarios where the API is down for some period of time or API is throttled. In such scenarios, it becomes very difficult to handle and process the message to the target system. Ultimately it affects the overall availability of the solution as we are not able to handle the downtime situation gracefully.


Solution :
To overcome the above problem, introduce a messaging layer to decouple the target from the source and at the same, the solution becomes more robust as the messaging queues level the load between the azure function/azure logic app and the target API. We introduce one more logic app/function app to poll the message from the queue and make a call to the Target API. With this approach, we can reduce the load on the target API during a high volume of traffic, and at the same time, we gracefully handle the messages while the target API is down as the message remains on the queue so that we can push the messages to the API once it is up and running.


References :
https://docs.microsoft.com/en-us/azure/architecture/patterns/queue-based-load-leveling