I have a very complex solution, written in C#/.NET 6, composed by Azure Service Triggers that use an API running as an Azure HTTP Trigger. There are 4 trigger function, each running up to 30 parallel sessions, and each session spans up to 10 processing tasks. Each task calls the API for accessing the resources concurrently. I am using Flurl serverless default behavior, configured for HTTP/2. All APIs are in the same endpoint, but with different paths, configured with Polly for retry strategy
For the loading tasks, I have a console app built using the same stack, calling the API that starts the processing up to 1000 times, while keeping the system running for processing the requests concurrently. Usually, the first 800 call runs properly, but after that, I start to have time-outs in both parts - the console app and the Azure functions. All the time, the CPU and memory allocation in the API is low <30%, but I can observe an increase in the number of sockets used for processing, but under the allowed limits.
The error reported is: TaskCanceledException - "The operation was canceled."
With the inner stack trace:
at System.Net.Http.Http2Connection.Http2Stream.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
at System.Net.Http.Http2Connection.Http2Stream.<ReadResponseHeadersAsync>d__74.MoveNext()
at System.Net.Http.Http2Connection.<SendAsync>d__111.MoveNext()
at System.Net.Http.HttpConnectionPool.<SendWithVersionDetectionAndRetryAsync>d__89.MoveNext()
at System.Net.Http.DecompressionHandler.<SendAsync>d__16.MoveNext()
at Microsoft.Extensions.Http.PolicyHttpMessageHandler.<SendCoreAsync>d__6.MoveNext()
at Polly.Retry.AsyncRetryEngine.<ImplementationAsync>d__0`1.MoveNext()
at Polly.AsyncPolicy`1.<ExecuteInternalAsync>d__23.MoveNext()
at Microsoft.Extensions.Http.PolicyHttpMessageHandler.<SendAsync>d__5.MoveNext()
at System.Net.Http.HttpClient.<<SendAsync>g__Core|83_0>d.MoveNext()
I noticed that my retry strategy is not triggered when the errors occurs. This hint me the call is not reaching the server, so the problem is not an overloading of resources there. I am also opening a ticket at Microsoft, but I would like to know if this there is something to be done on the client.
HttpClientinstances? Could you share a code sample to illustrate?