Azure Function usage on App Service Plan

Man 51 Reputation points
2022-07-25T10:21:41.25+00:00

I am trying to understand the usage of my function app under App service plan using python code but unable to figure out the details.

I first tested my function usage in my laptop. The function loads two files in memory and outputs the dimensions when the trigger is made. Using Jupyter Notebook, I loaded the 2 files and File-A consumed ~1.5GB and File-B consumed ~1GB. In total, in Jupyter notebook the memory consumption was ~2.5GB. Using the same files I want to understand the memory usage in Azure Functions.

Scenario1:
I created an Azure function to load only File-A using a HTTP trigger under consumption plan. Since Azure function has a memory of 1.5GB I expected this to work fine and it did. I was able to access the file dimension details using the HTTP link. Even the spike is little above 1.5GB it worked.

Scenario2:
Now, I also tried to load the File-B into the function along with File-A under the consumption plan. As expected I received an error code 5xx because the function exceeded the memory limit for the Consumption plan.

Scenario3:
In this scenario, instead of a consumption plan, I choose a dedicated App service Plan P1v3 - with 8GB RAM, as expected I was able to load both File-A and File-B into the Function and access the output using the HTTP link. But the usage here is confusing to me.

Below image is the memory usage under the function app. The first circle corresponds to Scenario1, 2nd circle correspond to scenario2, where as the third circle corresponds to scenario3.

224308-scenarios.png

When I read online about the function APP, I read it everywhere that function app can only hold maximum 1.5 GB of capacity and not beyond that but when I increase the capacity of my app service plan then I am able to load more than 1.5GB inside my function app.

So with the memory usage under scenario 3 going beyond what is defined for a function app (1.5GB). Does this mean Function app used/shared the memory from the App service plan server capacity?

At the same time, I also investigated the metrics from the application insight that was created along with my function app. Below is the image take at the same time as the one above. Here, I assume the server listed belongs to my Azure function where the memory usage is 339 MB which looks to mislead me. I was constantly monitoring this metric in all above scenarios and it kind of remained under the 400MB mark. But the image shown earlier under my function app says it consumes 1.5GB in the beginning and then 2.5GB.

224240-metrics.png

Now, I looked into my APP Service Plan, the Quotas for my App service plan shows the below details.

224361-file-system.jpg
As visible here, to me it looks like the APP Service Plan resource is shared by my function app as its listed in the quotas limit of the App Service Plan that I have chosen. But the memory usage here is different than the ones shown above.

Questions

  1. In the case of loading 2 files into memory when function loads and using HTTP as a trigger, when does Azure function scale to create a new 2nd instance for the function app?
  2. By default, does the Function app uses the resource of the app service plan might it be consumption (with 1.5GB memory limit) or App Service plan(8GB in my case with P1V3 VM)?
  3. How do I differentiate between the memory usage in the above 3 images?
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,909 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,930 questions
{count} votes

Accepted answer
  1. MughundhanRaveendran-MSFT 12,506 Reputation points
    2022-07-26T10:03:29.287+00:00

    Hi @Manash-2022 ,

    Thanks for reaching out to Q&A forum.

    From the scenario and your questions, I see that you need clarity on the memory usage of Function app in consumption and dedicated app service plan SKU. I will answer your questions in order

    (1) In the case of loading 2 files into memory when function loads and using HTTP as a trigger, when does Azure function scale to create a new 2nd instance for the function app?

    The scaling of the function app (serverless) is decided by the scale controller. It looks into multiple factors such as the incoming load (number of requests), CPU/memory utilization of the existing instance etc. So it is not just the memory usage of the function app. Only when all the factors are causing the instance to be exhausted, the scale controller votes to add a new instance.

    (2) By default, does the Function app uses the resource of the app service plan might it be consumption (with 1.5GB memory limit) or App Service plan(8GB in my case with P1V3 VM)?

    Yes. The Function app uses the resource of the App service plan depending on the SKU

    (3) How do I differentiate between the memory usage in the above 3 images?

    First image is the memory working set. The working set is the total amount of memory used by the process (w3wp.exe) which is private and unique to the process as well as shared memory
    used by the process such as shared libraries.

    Second image is the commited memory. It is the amount of virtual memory which is reserved, or committed, for the process. So it is not the utilization. Virtual memory come into picture when
    you run out of physical memory and another process asks for more memory the operating system needs a mechanism to ensure the requirements can be met.

    Third image is the File system storage . Please refer the below article for file system storage
    https://github.com/projectkudu/kudu/wiki/Understanding-the-Azure-App-Service-file-system

    Hope this helps! Feel free to reach out to me if you have any questions or concerns.

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.

    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.