Kaido
Kaido

Reputation: 4001

Why do my Isolated mode Azure functions not run in parallel?

My function app is Isolated mode B1

It contains http and queue triggered functions

The app only processes one request at a time and others wait for the previous to finish. This includes http requests made in parallel and queue triggers when the queues are all full.

I see that I can scale my app out to 2 instances, but is this really required to handle simultaneous requests?

Example Http function that takes 60 seconds to handle two concurrent calls:

 [Function("TestConcurrency")]
 public HttpResponseData Concurrency([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req)
 {
     var response = req.CreateResponse(HttpStatusCode.OK);
     response.WriteString("Concurrency");
     response.WriteString(DateTime.Now.ToString());
     Thread.Sleep(30 * 1000);
     response.WriteString(DateTime.Now.ToString());
     return response;
 }

Upvotes: 0

Views: 173

Answers (1)

Kaido
Kaido

Reputation: 4001

I was looking for app setting FUNCTIONS_WORKER_PROCESS_COUNT which has default 1

Async-await also frees up threads but starting with only 1 was my main problem

Upvotes: 0

Related Questions