Strange Latency Issue
Hello friends,
I have run into a strange latency issue that I would love to get some suggestions on where to dig. Let me describe our system.
We have a cluster of 6 silos, being called by 6 endpoint nodes sitting in front of them. The silos effectively have a single grain with 2 methods on it... it is serving as a smart cache of user-specific data... the grain retrieves the data via a REST service call, and stores it in two formats... Summary & Detail... and there is one method for retrieving each version of the data.
I have a GrainProfiler class that implements IIncomingGrainCallFilter & IOutgoingGrainCallFilter and is wired up to record metrics for grain method calls from both the client-side and the silo-side.
The average and 95th percentile latency that we see to both of these methods is in the 2-3ms range. When the data has expired, we make the REST call with a timeout of 450ms, but average latency for the call is in the 5-10ms range with tail latencies that spike to around 100ms generally. Our cache hit rate is around 95%.
Our Orleans Client Messaging Timeout is set to 1 second. In practice, the call to the REST endpoint effectively never fails. Our Endpoint calls to our grains are successful approaching 5 9's... but we do occasionally see timeouts calling grains. Occasionally, those timeouts manifest in a very strange way... we see latency (measured via my IOutgoingGrainCallFilter from the client) spike for a SINGLE client endpoint node for exactly FIVE minutes.

Exactly lining up with the start of that latency spike, I find a single call hitting the Messaging Timeout:
Response did not arrive on time in 00:00:01 for message: Request *cli/5baa999d@9c43099e->S10.0.109.156:30000:0*grn/EF6229D3/00673e17 #48439689. Target History is: <S10.0.109.156:30000:0:*grn/EF6229D3/00673e17:>.
When I look at the metrics logged by the IIncomingGrainCallFilter, I see no corresponding latency spike. Why would a single client timeout cause elevated latency on the client side for 5 minutes?
I searched the Orleans codebase for "TimeSpan.FromMinutes(5)" and "TimeSpan.FromSeconds(300)" and the most promising hit I found was this one: https://github.com/dotnet/orleans/blob/5356f648e246293ff2b028db4b77c106cd7b0e79/src/Orleans.Core/Runtime/GrainCancellationTokenRuntime.cs#L16
Any insight?
Also, forgot to mention that during one of those 5-min latency spikes, I found the logged failure at the start of it and hit that grain by manually calling the Summary endpoint... it returned fine, so the grain was not deadlocked or anything. The latency increase also only affected the method that timed out. The metrics for the other method showed no increase.
Nevermind... turned out to an interpolation issue on the dashboard.