I’m testing the CPU performance of functions, so I made a function that finds the prime numbers in a number. It is triggered by Azure Service Bus. On my local machine it runs in 350ms.
The function, when running in a consumption plan, takes around 1000ms. When I batch send 100 messages to the function, it does scale up to around 16 instances, but the performance of each function decreases considerably to between 3000-7000ms.
When trying a standard service plan with 4 cores, the performance is better, but not that much. It is still considerably slower than my laptop. This guy here has a similar issue.
Is this the performance/scaling to be expected from functions? E.q. not a great fit for batch processing of CPU intensive methods?
Would Azure batch be a better fit?
Azure functions are fast to execute because there is no large application, startup time, initialization, and other events fired before the code is executed. Azure functions' execution is triggered when an event is fired.
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.
Azure Functions are best suited for smaller apps have events that can work independently of other websites. Some of the common azure functions are sending emails, starting backup, order processing, task scheduling such as database cleanup, sending notifications, messages, and IoT data processing.
I don't know the exact specification of the hardware that Functions are running on, but you can assume that each instance of Consumption plan is a low-profile single-core VM. If you need to run CPU-intensive latency-critical workload, that's probably not a good match.
Your local machine is probably faster that those instances, so that's where 350ms vs. 1000ms difference comes from.
The decrease to 3000-7000ms is related to the fact that multiple executions of functions are running at the same time on the same instance. They are competing for CPU, slowing each other down. For pure CPU-bound workloads, you might be better off setting "maxConcurrentCalls": 1
in host.json
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With