Implement Rule-Based scaling in Logic App Standard via Logic App Consumption by info.odysseyx@gmail.com August 13, 2024 written by info.odysseyx@gmail.com August 13, 2024 0 comment 4 views 4 background As we know, Logic App Standard with WS ASP follows target-based scaling like Azure Function EP plan, which is mainly determined by job queue length rather than CPU/memory usage. However, in some situations, high CPU/memory usage can occur without a long work queue, resulting in the scaling controller not being able to vote to increase backend instances as expected. So in this blog, I will show you how to “simulate” rule-based scaling capability for Logic App Standard using WS Plan, a Logic App Standard running on ASE using Logic App Consumption (also possible with Azure products, e.g. Azure Function). machine Since we need to scale based on CPU/memory usage (and possibly other metrics), the first problem to solve is getting the metrics data: For example, if you want to know the average CPU usage, you can go to the CPU Percentage page and capture a HAR trace, and you will see that the APIs used in the portal are: https://management.azure.com/subscriptions/[SubscriptionID]/Resource Group/[ResourceGroup]/providers/Microsoft.Web/serverFarms/[ASP Name]/providers/microsoft.Insights/metrics?timespan=[StartTime]/[EndTime]&interval=PT1M&metricnames=CpuPercentage&aggregation=average&metricNamespace=microsoft.web%2Fserverfarms&autoadjusttimegrain=true&validateddimensions=false&api-version=2019-07-01 Once you have CPU usage data, you can calculate whether the current value has reached a threshold. If it has, you can change the number of always-ready instances by calling the management API.Web App – Update Configuration – REST API (Azure App Service) | Microsoft Learn). Implementation logic 1. Retrieve CPU usage for the last 2 minutes via API and calculate the average. 2. Retrieve the current number of Logic App backend instances and set the target number of instances to current. 3. Validate when average CPU usage reaches scale in/out threshold (>50% or <10%). If it is greater than the expansion threshold and the maximum number of instances (20) is not reached, add 1 instance to the target number of instances. If the minimum number of instances (1) is less than the threshold, remove one instance from the target number of instances. 4. Compare the current value with the target value and if they are different, always send a request to change the prepared instance. Sample Template A demo can be found here: Drac-Zhang/Rule-based scaling template (github.com) Implemented scaling feature based on CPU usage over the last 2 minutes. Meanwhile, for Logic App Consumption, you need to enable managed identity and assign “Reader” and “Logic App Standard Contributor” roles at the resource group level for MI. Known Issues 1. Since we are monitoring CPU/Memory usage at ASP level, we can have only one Logic App for ASP, but we can solve this by calling change metrics for CPU/Memory usage per Logic App. 2. Logic App Standard configuration API always prepares an instance. Current WS plan has a maximum of 20. 3. Due to collection delay, there is a delay of about 1 minute in retrieving metrics. Source link Share 0 FacebookTwitterPinterestEmail info.odysseyx@gmail.com previous post Position as Project Associate 2 at IISER Kolkata, WB, India next post Monitoring and Evaluation Officer | ReliefWeb You may also like Azure API Management Circuit Breaker and Load Balancing September 10, 2024 Microsoft at Open Source Summit Europe 2024 September 9, 2024 LLM Load Testing on Azure (Serverless or Managed-Compute) September 9, 2024 Day zero support for iOS/iPadOS 18 and macOS 15 September 9, 2024 Oracle Database@Azure, Microsoft Fabric, GoldenGate, Oracle September 9, 2024 Oracle Database@Azure, Australia east, Oracle, Azure, Data, AI September 9, 2024 Leave a Comment Cancel Reply Save my name, email, and website in this browser for the next time I comment.