[BUG] async functions are not being invoked in parallel
See original GitHub issueInvestigative information
Please provide the following:
- Timestamp: 10:08 PM August 7, 2020 (UTC)
- Function App name:
- Function name(s) (as appropriate):
- Core Tools version:
Repro steps
Provide the steps required to reproduce the problem:
Run two invocations of the HTTP triggered function provided below in parallel (at the same time.)
Expected behavior
Provide a description of the expected behavior.
When I invoke the above function twice at the same time, I expect both invocations to finish at the same time.
Actual behavior
Provide a description of the actual behavior observed.
The start and end times reported by the function show that the second invocation is being processed after the first one finished (i.e. after the sleep has finished and the first invocation has returned.)
azure-functions
azure-storage-blob==12.1.0
Related information
Provide any related information
- Links to source
- Bindings used
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Call async/await functions in parallel - Stack Overflow
The jsbin code appears to be executing promises in parallel, but they are not. When you create promise with new operator, the constructor...
Read more >Call Multiple async/await Functions Parallel or Sequential
To demonstrate call multiple async/await functions parallel, below is the function process which return promise after a specific time which are ...
Read more >Error handling with async/await and promises, n² ... - CatchJS
Yes, but only if the function was called with the await syntax, and only if resolve() has not been called for the promise...
Read more >Understanding the Event Loop, Callbacks, Promises, and ...
The key takeaway here is that callback functions are not asynchronous— setTimeout is the asynchronous Web API responsible for handling ...
Read more >Async.js
Synchronous iteration functions ... If you get an error like RangeError: Maximum call stack size exceeded. or other stack overflow issues when using...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@Hazhzeng One more thing I noticed is that if you call different functions of the same app in parallel, that works fine. So in this case, if you copy the same function and put it as function with a different name and invoke them at the same time, they in fact do get processed in parallel. It’s just that the same function is not being handled in parallel.
Really appreciate Gohar looking into the Python dispatcher code and raising the issue to me. This is a real issue as I discussed and did some experiments with Gohar.
Even when the function app is marked as async, the dispatcher is not picking up the next HTTP request when awaiting.
For example:
When invoking this HTTP trigger 3 times, the Http requests are still handled one after another, resulting 30 seconds of total execution time. What we suppose to see instead, is 3 HTTP requests executed in 10 seconds.
I think what Elvis said when he finished the project, is to expose the async interface to our customers in
asyncio.get_event_loop()andawait asyncio.wait(), rather than handling the async HTTP requests parallelly. (This explains why when Mark Russinovich tested our product, he uses his custom event loop to achieve parallel execution).I need to investigate more into this to find out the bottleneck where it prevents running multiple async HTTP requests. Meanwhile, to mitigate this issue, the customer can increase FUNCTIONS_WORKER_PROCESS_COUNT for spawning multiple Python processes.