Unleashing Cost Efficiency with Azure Functions
    • Dark
    • PDF

    Unleashing Cost Efficiency with Azure Functions

    • Dark
    • PDF

    Article summary

    #ServerlessTips - Azure Cost Management
    Author: Tidjani Belmansour Azure MVP

    This article is part of a series on the topic of Cloud Cost Optimization.

    While Cloud Cost Optimization requires robust monitoring, there exist some best practices that we’ll share with you throughout this series.

    The serverless computing model implemented by Azure Functions is a great way to optimize resources usage, since these resources are utilized only when needed.

    For Azure Functions, the cost is expressed as the product of the memory utilized (evaluated as GB/s) and the number of times the function is executed.

    Using the serverless computing model, we’re only billed per second of resources consumption. Hence, our costs increase as usage increases, and usage increases as we call the function more and more often.

    In a very simple way, we can represent it as follows:
    Unleashing Cost Efficiency with Azure Functions-1

    Fig 1. Cost evolution for an Azure Functions
    Compared to an App Service Plan, where we expect to pay a defined amount of money up-front, the serverless model is very appealing, especially if we don’t execute our function that so many times.

    In most event-driven scenarios, i.e., when your application or API is triggered in response to some specific event (such as a new user subscribing to your service, or an order being placed on your shopping site), you don’t know when such events will occur and hence when your application will get invoked. In such cases, relying on the serverless nature of Azure Functions will allow you to pay only when your application or API is invoked, which may lead to important cost savings, as you can see on this diagram:

    Unleashing Cost Efficiency with Azure Functions-2

    Fig 2. Consumption Plan vs App Service Plan

    Since no one can predict the future, our application / API running on an Azure Functions may become widely popular, and hence, ending up being called many times. In this case, you may be wondering how to avoid costs to become out of control.

    Don’t worry. Azure Functions allow you to define an upper scale limit, i.e., a maximum level of scale your Azure Functions can perform. With this, you can predict the maximum amount of money you may have to pay for your Azure Functions should it go widely popular.

    Should that happen, it would be more of good news rather than bad news, isn’t it? 😉

    For that matter, head over your Azure Functions instance in the Azure portal and go to “Scale out”. From there, you can enforce a scale out limit. As you can see, by default, it is 200 instances:

    Unleashing Cost Efficiency with Azure Functions-3

    Obviously, you can also define the scale limit through scripting and IaC.

    And there you have it! You can now leverage the serverless nature of Azure Functions to your Cost Optimization Strategy. But keep in mind that Azure Functions isn’t only about serverless pricing model, but also about an event-driven computing model.

    MicrosoftTeams-image 443

    Was this article helpful?