Handle multiple request by Azure Function

Viewed 519

I would like to ask how to deal with a situation when Azure Function is called many times at one moment?

Sample of code:

public static class SomeFunction
    {
        [FunctionName(nameof(TestFunction))]
        public static Task<HttpResponseMessage> TestFunction(
            [HttpTrigger(AuthorizationLevel.Function, "GET", Route = "Id/{id}")] HttpRequestMessage req,
            long id)
        {
            return await databaseService.GetById(id);
        }
    }

My questions:

  • Is it possible that my database gets timeout?

  • Has azure function a request's management mechanism?

  • It is good idea to use static concurrent collection to manage requests?

1 Answers

Depending on your App Service plan, Azure Functions scale automatically, So if you are expecting less than 100 concurrent invocations you don't need to worry about. (https://docs.microsoft.com/en-us/azure/azure-functions/functions-scale) For database connection, it depends on connection pool size and what kind of database you are using. In general, You don't need to maintain static concurrent collection unless until you expect sudden spikes in the requests and you are getting a throttling error.

Related