Optimizing Performance of Azure Functions with Dynamic Concurrency
    • Dark
      Light
    • PDF

    Optimizing Performance of Azure Functions with Dynamic Concurrency

    • Dark
      Light
    • PDF

    Article Summary

    #ServerlessTips - Azure Functions
    Author: Rahul Rai Microsoft MVP

    Azure Functions allows you to run multiple function invocations concurrently on a single Azure compute instance. As parallel invocations share the same computing resources, each function needs to be able to control how many concurrent invocations it can handle at any given time.

    Many Azure Function triggers expose settings to control the per-instance concurrency for the trigger type. For example, the Service Bus trigger provides both a MaxConcurrentCalls and a MaxConcurrentSessions setting that you can use to control the number of messages your function can process on each instance. However, setting optimal values for such settings can be challenging. Dynamic concurrency is designed to solve this problem by allowing each instance to handle as much work as possible while maintaining a low level of latency and keeping each instance healthy.

    Dynamic concurrency automatically adjusts your function concurrency settings as your load patterns change over time. Currently, dynamic concurrency can be used with the Azure Blob, Service Bus, and queue triggers.

    An in-depth explanation of dynamic concurrency can be found in the Microsoft Azure feature documentation.

    To enable dynamic concurrency in your function app that uses at least one of the supported triggers, edit the hosts.json file and add the following setting:

    {  
            "version": "2.0",  
            "concurrency": {  
                "dynamicConcurrencyEnabled": true,  
                "snapshotPersistenceEnabled": true  
            }  
        } 
    

    To access the hosts.json file, click on the App Service Editor option in the menu of your function app and then launch the editor by clicking on the Open Editor link as follows:

    MicrosoftTeams-image 512

    Figure 1: Launch App Service Editor

    The host.json file is present inside the WWWROOT directory. The file can be edited using the integrated editor as follows:

    MicrosoftTeams-image 522

    Figure 2: Edit host.json file

    MicrosoftTeams-image 491


    Was this article helpful?