Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Functions pricing and timeout

I've just noticed recently, that Azure functions acquired a 5 min timeout on the dynamic pricing tier somewhere along the timeline. As I've been busy doing other things, this flew under my radar, until I noticed some long running functions not completing.

So I went digging, and found out that there are two pricing tiers - the dynamic and the app service based. The site is a bit vague on the whole concept, but as I understand it, this is how it stands:

Dynamic: Charged per usage time and memory allocation by the user. 5 minute timeout (so useless for one time long running operations now).

App service: Either a basic or standard tier VM, running full time, waiting for triggers. No timeout to speak of.

Now the first disappoints me, as I saw functions as a solution for my jobs that need to be fired once or twice per year, but then take a day or two to complete (comprehensive backup and data packaging for export).

The second confuses me - does this mean, that the stateless function now runs as a web app and I am to be charged for it as such? If this is the case, the whole concept of functions is now useless for my purposes, unless I implement a Cell processor, firing 80000 function instances upon a trigger to get the work done on time. If that's even possible.

Could someone please explain the model behind Functions pricing and what the best solution for my problem would be?

Thank you.

like image 409
JasonX Avatar asked Nov 25 '16 08:11

JasonX


People also ask

Do Azure functions have a timeout?

For more information, see Improve Azure Functions performance and reliability. Regardless of the function app timeout setting, 230 seconds is the maximum amount of time that an HTTP triggered function can take to respond to a request. This is because of the default idle timeout of Azure Load Balancer.

How long does an Azure function last?

How Long Can Azure Functions Run? For any Azure Functions, a single Function execution has a maximum of 5 minutes by default to execute. If the Function is running longer than the maximum timeout, then the Azure Functions runtime can end the process at any point after the maximum timeout has been reached.

What is default timeout for Azure functions in Consumption plan?

Azure Functions can now run up to 10 minutes using the consumption plan by adding the functionTimeout setting to your host. json file: In a serverless Consumption plan, the valid range is from 1 second to 10 minutes, and the default value is 5 minutes.

How long can an Azure function run for on Consumption plan 1 minute 5 minutes 10 minutes 15 minutes?

Standard Azure Functions (not Durable Functions) have a maximum timeout of 10 minutes on a consumption plan.


1 Answers

This thread deserves a bit more clarity. Firstly, If your function call takes some time to complete, you are going to want it to be async. Secondly, If you do make it async, it will not timeout after 5 mins.

Give it a shot :P

DateTime d = DateTime.Now;
Task t = new Task(() =>
{
    log.Info("Doing long task");
    for (int cnt = 0; cnt < 100; cnt++)
    {
        log.Info(DateTime.Now.Subtract(d).ToString());
        System.Threading.Thread.Sleep(10000);
    }
});
t.Start();

I am currently running them on a consumption plan for more than 5 mins, as per my post. There is a timeout, but it’s not on execution time obviously since I am running them longer than 5 mins. The time out is in the calling mechanism that executes the function. If you make it async, the caller returns and the function continues to execute. It is a common practice to put long running tasks on a separate thread/process than the calling thread/process. Keeping the orchestration layer of the function platform from blocking for long periods of time just makes sense. You should not block the calling layer for long running functions as it will seriously degrade the platform.

like image 54
William Wallace Avatar answered Sep 22 '22 12:09

William Wallace