I’m seeing unpredictable occasional slow outbound HTTP requests within an invocation on an Azure Functions on a Linux Consumption plan. Runtime v3.0.15417.0. Can replicate in Au-East and US-Central. Problem doesn't occur on Windows Consumption plans.
I'm looking for an explanation why this might be occurring.
My function makes 10 outgoing calls to http://www.google.com. It sleeps for 0.2 seconds between calls. All Http calls are synchronous (I know I can optimise this but initial problem initially came in a Python consumption plan function using CosmosClient which does not support async io).
Calling the function
I have an external script that calls the function 20 times sequentially from my local machine.
I'd expect to see similar execution times for the invocations.
I get wildly unpredictable results. It's extremely easy to reproduce on any Linux Consumption plan.
Windows Consumption plans produce steady more predictable response.
75% of the runs are about 4.5 seconds. But often, midway through an invocation, one of the requests might take up to 8 seconds. My hunch is it is being forced to wait to get a socket by the underlying runtime, but I have no way to prove this.
There are no cold starts involved. I can see from my log statements that it may be the 3rd, 4th, 5th, 6th or 7th request within a function invocation that often takes many seconds to respond.
There is no concurrency involved. My test harness calls the function sequentially.
I can recreate similar results using a variety of Uris. I originally saw the problem using CosmosDB.
Any explanations on what might be happening would be great.