Need deeper understanding of azure functions

D 46 Reputation points
2022-11-17T12:50:44.893+00:00

I have been using Azure functions but I am looking for in-depth knowledge related to it. Below are my questions:

  1. I have 100 HTTP functions in my single Azure function app, Will they all run on a single Virtual Machine?
  2. If I call all 100 functions simultaneously from my different applications, will these all 100 functions use the same memory of the VM?
  3. Does memory is allocated to each function or to the full-function app?
  4. What is the meaning of a function instance? If I make 10 HTTP calls to a single HTTP function, How many instances will be created for that function?

It would be great if someone can give insights on these points. Thanks in advance!

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,909 questions
0 comments No comments
{count} votes

Accepted answer
  1. MughundhanRaveendran-MSFT 12,506 Reputation points
    2022-11-23T16:05:17.073+00:00

    @D ,

    Thanks for posting your query in Q&A forum.

    (1) I have 100 HTTP functions in my single Azure function app, Will they all run on a single Virtual Machine?

    From the above conversation, I got to know that your function is in Premium plan. For premium plan, the scaling is controlled by the scale controller. Depending upon the incoming http traffic and the existing instances, the scale controller would decide to increase/ decrease the number of instances. So even if you have 100 functions and the incoming load is very less and the exisiting VM can handle this load, then there wont be any scaling. In other words, it can continue to run in single VM given the fact that the single VM is able to handle the load.

    (2) If I call all 100 functions simultaneously from my different applications, will these all 100 functions use the same memory of the VM?

    The memory is allocated to the Function app(w3wp.exe process) on the whole and not to individual functions. Lets say the function app is running on 2 instances (1 pre-warmed instance and another instance), function app would have 3.5GB + 3.5 GB (EP1 plan) to consume. As you mentioned, all 100 functions would be using the same memory as they are all under 1 Function app. If the memory utilization is high, the scale controller would add another instance.

    https://learn.microsoft.com/en-us/azure/azure-functions/functions-premium-plan?tabs=portal#available-instance-skus

    (3) Does memory is allocated to each function or to the full-function app?

    Answered in (2)

    (4) What is the meaning of a function instance? If I make 10 HTTP calls to a single HTTP function, How many instances will be created for that function?

    You can consider an instance to a VM running the Function app. 2 function instances means there are 2 vms running the Function app. Again, scaling is completely controlled by scale controller, for premium plan you can set max burst,minimum instances and always ready instances. To answer your question specifically, 10 requests can be easily handled by single instance.

    https://learn.microsoft.com/en-us/azure/azure-functions/functions-premium-plan?tabs=portal#always-ready-instances

    2 people found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Sreeju Nair 12,666 Reputation points
    2022-11-17T13:30:49.79+00:00

    Basically, the function app provides the execution context in which all the functions under the function app will run. A function app is comprised of one or more individual functions that are managed, deployed, and scaled together. All of the functions in a function app share the same pricing plan, deployment method, and runtime version.

    Refer: https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference?tabs=blob

    While creating a function app, you can choose the hosting plan which determines how your app scales. With this let me provide the answers

    1. I have 100 HTTP functions in my single Azure function app, Will they all run on a single Virtual Machine? : This is based on the hosting plan for your app. Refer Consumption plan, Premium plan, and Dedicated (App Service) plan.
    2. If I call all 100 functions simultaneously from my different applications, will these all 100 functions use the same memory of the VM? The resource consumption is based on the hosting plan for your function app. The functions under the function app share the resources.
    3. Does memory is allocated to each function or to the full-function app? (Same answer as above)
    4. What is the meaning of a function instance? If I make 10 HTTP calls to a single HTTP function, How many instances will be created for that function? I believe you are referring to the concurrent function invocations. Multiple function invocations can run on each instance concurrently, each function needs to have a way to throttle how many concurrent invocations it's processing at any given time. Refer: https://learn.microsoft.com/en-us/azure/azure-functions/functions-concurrency

  2. Damilola Adejobi 0 Reputation points
    2023-10-11T15:39:27.8366667+00:00

    Azure Functions is a serverless compute service that allows you to run event-driven code without managing the underlying infrastructure. Let's break down your questions one by one:

    Will all 100 HTTP functions in my Azure Function app run on a single Virtual Machine?

    Azure Functions runs on top of the Azure App Service infrastructure, which abstracts the underlying infrastructure details. When you have multiple functions in the same Function App, they can run on the same VM or on different VMs. The scaling and distribution of function instances depend on the incoming load and the configured settings.

    If I call all 100 functions simultaneously from different applications, will they all use the same memory of the VM?

    The memory used by your functions depends on the number of instances that are created to handle the incoming requests. Each function execution runs in its own isolated environment, and Azure Functions can scale out by creating multiple instances to handle concurrent requests. Each instance has its own allocated memory, which is managed independently. So, when you call all 100 functions simultaneously, they may or may not share the same VM, but each function instance will have its own allocated memory.

    Is memory allocated to each function or to the full function app?

    Memory is allocated to individual function instances, not the entire Function App. Each function instance is allocated its own resources, including memory, and they are isolated from each other. The amount of memory allocated to each function instance is determined by the App Service Plan or Consumption Plan configuration you have set up.

    What is the meaning of a function instance? If I make 10 HTTP calls to a single HTTP function, how many instances will be created for that function?

    A function instance is a specific execution of a function. When you make HTTP calls to a function, Azure Functions may create multiple instances to handle those requests simultaneously. The number of instances created depends on the scaling settings and the level of concurrency configured for your Function App.

    In the case of making 10 HTTP calls to a single HTTP function, if your Function App is configured to handle 10 concurrent requests and all of them arrive simultaneously, Azure Functions might create 10 instances to process these requests in parallel. If your scaling settings allow for more concurrency, it might create more instances.

    Function instances are short-lived and are created as needed to handle incoming requests. Once the execution is complete, the instances may be reused for subsequent requests, or they can be scaled down if the demand decreases.

    Keep in mind that Azure Functions are designed to be scalable and can automatically scale based on the configured settings and incoming workload, so the actual behavior may vary depending on your specific configuration and usage patterns.

    0 comments No comments

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.