Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Functions memory / consumption unit usage

Is it possible to view memory usage / how many consumption units you are presently/historically using for Azure Functions?

I'm currently using the consumption plan for a function which handles messages from a service bus queue. Each message takes around 5 seconds to process and there are usually several hundred messages / second to be handled.

My fear is simply that at some point I will starting seeing outofmemoryexceptions with no forewarning, though it would also be helpful for me to get an idea of costing before being billed.

I've looked through the portal and all I've found is the success count and pulse (which never seems to report any data for my function. Though the graphs are drawn - they are always empty.)

There is also this blog post:

https://blogs.msdn.microsoft.com/appserviceteam/2016/11/15/making-azure-functions-more-serverless/

..which essentially says that you do not need to specify your memory cap anymore and providing your usage is within 1.5GB & your processing is under the 5 minute timeout then life is good. Knowing how much room I have would be reassuring though!

like image 956
Nosmadas Avatar asked Dec 30 '16 16:12

Nosmadas


People also ask

What are Azure function execution units?

Function execution units are a combination of execution time and your memory usage, which makes it a difficult metric for understanding memory usage. Memory data isn't a metric currently available through Azure Monitor.

How long can an Azure function run for on consumption plan?

Standard Azure Functions (not Durable Functions) have a maximum timeout of 10 minutes on a consumption plan. This is the same timeout for the new Function Runtime ~4 (missing in the link).

Which properties of Azure functions are used for billing when the consumption plan is used?

Consumption. Azure Functions consumption plan is billed based on per-second resource consumption and executions.


2 Answers

The simple answer to your question is "yes".

Use the Azure Monitor Metrics REST API to get FunctionExecutionUnits and FunctionExecutionCount metrics.

This sample call:
az monitor metrics list --resource /subscriptions/<subid>/resourceGroups/pbconsumptionexample/providers/Microsoft.Web/sites/pbconsumptionexample --metric FunctionExecutionUnits,FunctionExecutionCount --aggregation Total --interval PT1M

yields the following sample output shows 153600 MB-milliseconds, or .15 GB-ms:

"name": {
    "additionalProperties": {},
    "localizedValue": "Function Execution Units",
    "value": "FunctionExecutionUnits"
  },
  "resourceGroup": "pbconsumptionexample",
  "timeseries": [
    {
      "additionalProperties": {},
      "data": [
        {
          "additionalProperties": {},
          "average": null,
          "count": null,
          "maximum": null,
          "minimum": null,
          "timeStamp": "2018-04-13T23:40:00+00:00",
          "total": 153600.0
        }
      ],
      "metadatavalues": []
    }
  ],

Here's an explanation of how:

https://github.com/Azure/Azure-Functions/wiki/Consumption-Plan-Cost-Billing-FAQ#how-can-i-access-execution-count-and-gb-seconds-programmatically

For greater context:

https://github.com/Azure/Azure-Functions/wiki/Consumption-Plan-Cost-Billing-FAQ

like image 95
Greg Oliver Avatar answered Sep 18 '22 04:09

Greg Oliver


You can use the Monitor -> Metrics view in the Azure Portal:

enter image description here

For more information on this topic see this functions cost/billing FAQ.

like image 36
Paul Batum Avatar answered Sep 21 '22 04:09

Paul Batum