8

Is there a performance benefit of choosing the azure function vs the http request action?

There seems to be two ways to add an azure function to your logic app.

The first way is to simply trigger an Http Request:

enter image description here

Alternatively, we can choose Azure function as the action:

enter image description here

Is there a performance benefit of choosing the azure function vs the http request action?

deceze
  • 510,633
  • 85
  • 743
  • 889
Alex Gordon
  • 57,446
  • 287
  • 670
  • 1,062
  • 1
    The http trigger is more generic as it can handle any kind of http request. I would say if you have an azure function, use the azure function action as the function key won't be visible (security). – Thomas Mar 18 '19 at 19:44

3 Answers3

5

There is no control over how quickly azure functions are invoked and their performance is tied to the plan selected. MSDN's Understanding Serverless Cold Start and this blog post explain there is a 2 - 10 second overhead when calling an azure function that have not been called recently. The start up time depends on the language it is written it and its dependencies. Running your azure functions using a dedicated plan avoids the problem.

An http request only has a drawback of making an HTTP call. This action is preferable when calling an API and the response does not need to be heavily processed.

Calling an azure function through an API using an http request should be avoided because it incurs the cost of two operations. Presumably an azure function is not invoked via a simple HTTP when chosen directly.

Noremac
  • 554
  • 2
  • 7
  • this is really great info, thank you, however, i'm still interested in understanding what is the mechanism that calls an azure function binding vs an azure function via http and whether one is hugely preferable over the other, specifically does msdn address this? – Alex Gordon Mar 19 '19 at 14:58
5

When we're talking about a performance of Azure Function we must discuss them in a context of the following issues: high CPU / memory consumption, port / outbound_socket consumption, number of spawned_threads / pending requests, etc.

There's one important thing you need to bear in mind: while creating a Function App a developer should keep in mind the fact that moving from Consumption Plan to App Service Plan (or vice-versa) is impossible once the function has created. But if he deletes the Function app and recreates it on the other type of hosting plan then that is possible for obvious reasons. A developer should design a function app in a way avoiding performing an intensive tasks taking high CPU and memory consumption, spawning large number of threads, opening large number of outbound socket connections, etc.

The best practises for improving performance of Azure Functions are:

  • avoid long running functions
  • use storage queues for cross function communication
  • write functions to be stateless
  • write defensive functions
  • re-use connections to external resources whenever possible
  • use async code and avoid blocking calls

Once the application usage gets past to these limits the processing rate of messages gets reduced and then the scale controller adds a new instance of a machine and the load gets distributed to keep up the processing rate. However, it takes about 10 seconds to add a new instance and then the load balancing of the events starts. However when the new instances are added then processing speeds up and within 20-30 minutes, the high load (10,000 requests) will be settled.

Conclusion: Azure Functions' performance depends on a variety of factors.

Hope this helps.

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
3

You can just consider azure function as Webhook to be a more specific version of an HTTP request. The major difference being that WebHooks are generally configured to only respond to POST requests where as HTTP Requests can be used with all REST Verbs.

Link related to:

https://www.vainolo.com/2018/10/22/azure-functions-part-3-handling-http-query-get-and-post-requests/