Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A lot of time spent in Result execution with eventual exception in kestrel #57953

Open
senioroman4uk opened this issue Sep 18, 2024 · 2 comments
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue.

Comments

@senioroman4uk
Copy link

Hi, I was trying to diagnose an issue that we observe for a small population of slow failing requests in production (less then 1%).
Our service is hosted on Kubernetes Linux (Azure Linux V2). From global traffic routing we use Azure Traffic Manager, so clients connect to the service directly.

We use mariner base images mcr.microsoft.com/dotnet/aspnet:8.0-cbl-mariner2.0

dotnet --info

Host:
  Version:      8.0.8
  Architecture: x64
  Commit:       08338fcaa5
  RID:          linux-x64
 
.NET SDKs installed:
  No SDKs were found.
 
.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.8 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 8.0.8 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
 
Other architectures found:
  None
 
Environment variables:
  Not set
 
global.json file:
  Not found

We log duration of various parts of MVC pipeline via filters (action, result and resource filter) and also measure an entire request duration via middleware. For these slow requests we observe a lot of time spent in result execution (for example 969520 ms) with an eventual exception from kestrel

 at System.Net.Security.SslStream.WriteAsyncInternal[TIOAdapter](ReadOnlyMemory`1 buffer, CancellationToken cancellationToken)
   at System.IO.Pipelines.StreamPipeWriter.FlushAsyncInternal(Boolean writeToStream, ReadOnlyMemory`1 data, CancellationToken cancellationToken)
   at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token)
   at System.IO.Pipelines.StreamPipeWriter.CompleteAsync(Exception exception)
   at System.IO.Pipelines.StreamPipeWriter.CompleteAsync(Exception exception)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.DuplexPipeStreamAdapter`1.DisposeAsync()
   at Microsoft.AspNetCore.Server.Kestrel.Https.Internal.HttpsConnectionMiddleware.OnConnectionAsync(ConnectionContext context)
   at Microsoft.AspNetCore.Server.Kestrel.Https.Internal.HttpsConnectionMiddleware.OnConnectionAsync(ConnectionContext context)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure.KestrelConnection`1.ExecuteAsync()
InnerException type:System.Net.Sockets.SocketException message:No route to host stack:   at System.IO.Pipelines.Pipe.WriteAsync(ReadOnlyMemory`1 source, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.DuplexPipeStream.WriteAsync(ReadOnlyMemory`1 source, CancellationToken cancellationToken)
   at System.Net.Security.SslStream.WriteSingleChunk[TIOAdapter](ReadOnlyMemory`1 buffer, CancellationToken cancellationToken)
   at System.Net.Security.SslStream.WriteAsyncInternal[TIOAdapter](ReadOnlyMemory`1 buffer, CancellationToken cancellationToken)

I would like to get some help identifying the root cause of this issue

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions label Sep 18, 2024
@captainsafia
Copy link
Member

@senioroman4uk Can you share more details about whether or not this bottleneck occurs for a specific result type? I know that getting minimal repros for these kinds of issues can be hard but additional info about when it happens would be appreciated.

@captainsafia captainsafia added the Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. label Sep 19, 2024
Copy link
Contributor

Hi @senioroman4uk. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue.
Projects
None yet
Development

No branches or pull requests

2 participants