-
Notifications
You must be signed in to change notification settings - Fork 866
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
YARP latency - less requests = more latency, more requests = less latency #2730
Comments
Hey, thank you for including the timings upfront :) I'm guessing that the logic to collect them is about the same as the metrics sample in this repo? IMO these are the interesting bits to look at
The fact that you never saw a The The only thing that differs is the |
Another guess since your latency is suspiciously close to 1 second: that happens to be the default Is it possible that the server behind YARP doesn't support the mechanism? Might not be the case since your requests don't appear to have a request body though. |
My pleasure :) Yep, I copied your sample and used the same middleware code to write the timings to App Insights. The backend currently doesn't have additional asp.net core timings enabled, other than OTEL. Identity Server and YARP respectively run in a .net core 8 web api in Azure. Both services run on a scaled out to 2 instances P1v3 sku (Not very busy). I'll have a look at that header but I guess its supported in Azure App Service for Windows with .NET 8? In production, requests come from a wide area of clients which might indeed send that specific one. Our synthetic client doesn't - its a C# Console App using a HttpClient. Having a 99th percentile of 1.03 secs with over 2 mil requests smells like something internal.. |
@MihaZupan I'm closing this one as YARP does not seem to be the culprit. Thanks for your help! |
Were you able to track down where the latency was coming from? |
@MihaZupan Not quite, after enabling some more logging we noticed the latency increase happens just after
Some more samples
That log-statement is done here, which is probably the last few lines of code before sending the to be proxied request downstream?: We'll be involving Azure Support as well as there seems to be an issue between two App Services. We're also trying to reproduce the latency with a Linux App Service (Currently windows) |
Double-checking the tracing implementation, I misspoke before
Where this could change is if the server is sending back interim 1xx responses right away, but the actual response takes a while. Or if something delayed the headers part of the traffic for some reason. Given that this is happening in P99 it should still be relatively common. Would you be able to capture a network trace that included such slow requests? With these timings, this is very unlikely to be an issue in YARP itself. |
@MihaZupan Sorry for the late reply. A typical request flow looks like this in our infra (We're using Azure VWAN and Private Endpoints) client --> Azure Front Door --Private Endpoint--> Azure App Service (YARP) --Private Endpoint--> Azure App Service (Cluster) We do have Network Security Groups in place but disabling them had no impact. I'll be running a few network traces in Azure, using a direct route to the cluster and over YARP to see if there is anything significant in between (Eg. Azure Networking) |
We ran network traces from the apps running YARP to the destination and will open up a case with Azure Support as the application layer (based on logs) does not seem to be responsible for the latency. |
Describe the bug
We are running Duende Identity Server in a production environment with YARP in front. We started seeing reduced latency beginning on 8th of january. See DuendeSoftware/Support#1565 for more the Identity Server side details. The STS endpoint basically returns a cached response in json (OpenId Discovery Document).
Further technical details
Yarp.ReverseProxy Version: 2.2.0
NET8
Azure App Services are windows
We run Identity Server load-balanced over two regions with Azure Front Door and each region has its own YARP instance with idsrv as single cluster, they're connected through private endpoints.
PaaS resource usage is below ~5% in all aspects (DB, App Service Plan cpu, memory etc.)
The 99th percentile over a span of 7 days with ~2.6 mio requests of the two specific endpoints is almost exactly 1.03 second.

When we increased requests through a synthetic source, the latency went back to normal
Seeing this, we thought about some keep alive / overhead when establishing new tcp connections?
Further request details here: The Yarp instance is represented by the first two spans, the request is then forwarded to idsrv.
A fast request
Captured diagnostics:
A slow request
Captured diagnostics:
Let me know if you need further information. We're using a standard YARP setup with 1:1 forwarding over a cluster / route config.
The text was updated successfully, but these errors were encountered: