V
V
vvovas2020-08-28 16:03:19
Python
vvovas, 2020-08-28 16:03:19

Where to look for the reason for the Python function scalability limit in Azure Functions?

There is a Python code that works with the OpenCV library. I decided to try hosting it on Azure Functions in order to be able to run calculations in parallel.

I uploaded the code to Function App (Consumption plan/Free trial subscription) and made several test runs of 2,4,8,16 calls at the same time.
The function code is executed (judging by the logs) ~15 seconds, the results of the launches were as follows:
2 requests - ~30 seconds.
4 requests - ~32 sec.
8 requests - ~35 sec.
16 requests - ~60 sec.

Here is an excerpt from the logs of one of the launches (the start of the function and the execution of the first command are separated by 50 seconds):

2020-08-28 08:05:48.335 Executing 'Functions.FuncName' (Reason='This function was programmatically called via the host APIs.', Id=6ce3ec9b-6b32-4ec1-80e8-533124fa28bd)
2020-08-28 08:06:37.698 Python HTTP trigger function processed a request.


The input function is marked as async in the code:
async def main(req: func.HttpRequest) -> func.HttpResponse:
    return func.HttpResponse(await do_work(req))


I have read the documentation and all I have found is:
  • A single function app only scales out to a maximum of 200 instances. A single instance may process more than one message or request at a time though, so there isn't a set limit on number of concurrent executions. You can specify a lower maximum to throttle scale as required.
  • For HTTP triggers, new instances are allocated, at most, once per second.

, which does not really fit with the launch results.

Actually questions:
1. Why parallel start of 2 functions is executed on time approximately as much as serial?
2. Why running more than 8 functions in parallel starts to delay execution?
3. Is there a scalability setting anywhere?
4. Maybe using Azure Functions for Python+OpenCV is not the best idea? Where else can you deploy such a function in order to be able to run calculations in parallel?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2020-08-28
@dimonchik2013

Actually questions:

look, if you replace your functions with parsing URLs, preferably different ones (so that the server does not lock up from the other side), you will see 500-100 without difficulty
and without difficulty - and you don’t want to work a fish from the pond
and call on extra-SEXs, in the calculation that they will chew what you didn’t learn in the manuals and SICP
, for example,
Why does running more than 8 functions in parallel start to delay execution?

knowing that OCV is primarily a PROCESSOR, you hope to sew on hats by simply changing the number 2-32
or
Why does the parallel launch of 2 functions take about the same time as the sequential one?
you don’t remember how a thread is created and resources are allocated,
and so on.
in short - the best way to OCV is only and only multiprocessing
xs what kind of tasks you have - maybe you can put 8 per core
and running more than 8 functions starts to delay

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question