Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CPU, RAM and I/O intensive code runs slowly on Azure Functions

We have some code that is fairly CPU, RAM and I/O intensive (it creates lots of temporary files, decompresses, resizes and compresses images). We're trying to integrate this into a "serverless" web application, and seeing as our code only runs on Windows at the moment we're testing it on Azure Functions.

We've observed that our code runs considerably slower on Azure Functions than it does on my local workstation (Core i7-4790, 16GB RAM, SSD). For example, one typical workload gives us these timings:

Dev workstation:                                2.47 sec
Azure Functions, "App Service" plan (S3 size): 10.59 sec
Azure Functions, "Consumption" plan:           15.96 sec

We've also found that on the "Consumption" plan, timings vary quite widely - one particular job gave us times varying between 112 and 153 seconds. The same job on the S3 "App Service" plan took between 117 and 119 seconds, and around 31 seconds on my workstation.

Timings on P3 were similar to S3, which is about what I expected as the CPU and RAM specs are the same.

So I have a few questions really:

  1. Is there anything we can do to profile our application running on Azure, to identify where the bottlenecks might be?
  2. Are we crazy to be trying to run such a heavy workload on Azure Functions?
  3. Does anyone have any suggestions as to how we could get our code running on more powerful hardware without swallowing all the complexity of managing a farm of virtual machines?
like image 752
Anodyne Avatar asked Jun 06 '17 14:06

Anodyne


People also ask

How much memory can an azure function use?

Memory used by a function is measured by rounding up to the nearest 128 MB, up to the maximum memory size of 1,536 MB, with execution time calculated by rounding up to the nearest 1 ms. The minimum execution time and memory for a single function execution is 100 ms and 128 mb respectively.

How long can an azure function run for on consumption Plan 1 minute 5 minutes 10 minutes 15 minutes?

Guaranteed for up to 60 minutes.

Are Azure functions fast?

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.


1 Answers

  1. You can profile App Service app (including Function App) remotely, see this link. I used Kudu and it worked good.

  2. Really depends on your targets. The timings that your quoted can be perfectly fine for some applications.

  3. This seems to be too broad a question for SO.

A more FunctionApp-ish approach would be to try to break down your long-running function into smaller short-running functions, and thus break down and potentially parallelize the processing.

like image 180
Mikhail Shilkov Avatar answered Nov 08 '22 17:11

Mikhail Shilkov