Azure Python Function - [HostMonitor] Host CPU threshold exceeded

Nic Markram 30 Reputation points
2023-09-22T14:42:24.2233333+00:00

I am running a python v2 azure function app (consumption plan) using a blob storage trigger. I have 2 functions monitoring 2 different containers and when a new blob arrives, it grabs the blob and inserts it into a DB.

The script is extremely lightweight and the blob sizes are miniscule (a few kb). On average, I am getting around 1000 blobs per day. In app insights logs stream I see a huge amount of "[Warning] [HostMonitor] Host CPU threshold exceeded (81 >= 80)".

I am not sure how to handle this? Does this mean my function itself is too heavy for each instance? Is it because I have too many concurrent requests?

Thanks in advance

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,902 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,792 questions
{count} votes

Accepted answer
  1. navba-MSFT 23,800 Reputation points Microsoft Employee
    2023-09-25T04:39:07.8433333+00:00

    @Nic Markram Welcome to Microsoft Q&A Forum, Thank you for posting your query here!

    I understand that you are encountering many warning messages [Warning] [HostMonitor] Host CPU threshold exceeded (81 >= 80) for your Azure function app.

    Refer to this document: Host Health Monitor · Azure/azure-functions-host Wiki · GitHub, the actual thresholds used by the monitor are a percentage of these maximums (default is 0.80).

    Please consider reducing the concurrency calls per instance and check if that helps. Refer this.

    For a function app that processes a large number of I/O events or is being I/O bound, you can significantly improve performance by running functions asynchronously. For more information, see Improve throughout performance of Python apps in Azure Functions.

    Also try to add the app setting "FUNCTIONS_WORKER_PROCESS_COUNT" and set the value in between 2 and 10. This setting specifies the maximum number of language worker processes, with a default value of 1. Start from lower value and try increasing it slowly until you find the optimal value for your app.

    https://learn.microsoft.com/en-us/azure/azure-functions/functions-app-settings#functions_worker_process_count

    You can set the value of maximum workers allowed for running sync functions using the PYTHON_THREADPOOL_THREAD_COUNT application setting. For mixed workloads apps, you should balance both FUNCTIONS_WORKER_PROCESS_COUNT and PYTHON_THREADPOOL_THREAD_COUNT configurations to maximize the throughput. Start from lower value and try increasing it slowly until you find the optimal value for your app.

    Please refer this article for more information about Python Function App performance optimization.

    Also read the below comment for similar issue from this github thread.User's image

    Also See how dynamic concurrency works in Azure Function App with a simple test. More info here.

    To Improve the performance and reliability of Azure Functions, refer this article.

    **

    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.