Orleans gets slower over time
Hi,
it is a little bit vague, but I have the impression that Orleans gets slower over time.
My specs are:
- .NET Core 2.0
- Running on Kubernetes in GCloud, 2 Nodes/Silos
- Co-Hosted with ASP.NET Core
I have a very simple grain, that just returns the snapshot (my own state system):
https://github.com/Squidex/squidex/blob/master/src/Squidex.Domain.Apps.Entities/Schemas/SchemaGrain.cs#L305
I use my own serializer with JSON.NET and my benchmarks show that the serialization takes 2-3 ms usually. I also tested it with 100x larger states that expected and the performance is great.
I added some profiling to the client side and I have experienced that the call takes 4-5 ms after I deploy it and several days later up to 200ms or even more (the max I have seen is 10seconds).
I also checked my MongoDB logs where I save all slow queries and there is nothing related.
I am a little bit lost.
that seems odd. do you have memory dump from the server? if logs cannot give us anything with good insight, maybe memory dump will, because this looks like something slowly grow bad in the server.
Or do you monitor the memory and cpu use on the server? that might be an easier starting point than memory dump
Sorry, it is kubernetes cluster. No idea how to get a memory dump from the process. I observe the monitor and cpu usage, but there is nothing special.
There was also a short discussion on gitter and @DarkCow said:
I have noticed increasing timeout's orleans-2.0.0, I have deployed orleans-2.0.0-ci.20180417.4 which includes the replacement threading model by @dVakulen which seems to solve the problem.
As far as I can tell, what I am seeing is that a thread will deadlock/stall, it is hard to find which Orleans function is stalling. But the new threading model seems to be a work stealing queue. #3792 Yes, been in production since 4/19. This is the first I am seeing other people having performance problems after hours of runtime...
Yeah, I went through the pipeline, everything in Orleans is really fast, but there is something else stalling the execution. Are you seeing warning logs about Task ... took elapsed time 0:00:00.4702115 for execution, which is longer than 00:00:00.2000000. Running on thread System.Threading.Thread and then Response did not arrive on time in 00:00:30 for message
I don't see these warning messages for first 12+ hours of runtime, then they start cropping up. orleans-2.0.0-ci.20180417.4 has appeared to of solved it and/or masked it...
I am seeing a similar issue. I have a 17VM cluster, running on Microsoft server 2012r2, net core 2.0, I am using the standard code-gen serializer, ADO.NET for clustering/storage/reminders. and SimpleMessageStreaming for streams.
The issue After 12+ hours of runtime, Orleans begins to have problems with grain calls stalling. These grain calls are fine T<12 hours, but stall T>12 hours. Some calls are fast, but they are interleaved with slow grain calls.
Task ... took elapsed time 0:00:00.4702115 for execution, which is longer than 00:00:00.2000000. Running on thread System.Threading.ThreadResponse did not arrive on time in 00:00:30 for message ...
Things I've investigated
- Grain calls are 100% async await, there is no blocking IO calls.
- Trace grain calls to specific grain code. There is no correlation between timeout warnings and code complexity. Some calls are
Return Task.FromResult( State ); - RAM usage, CPU usage and there are no leaks and/or CPU spikes.
- A timeout warning does not correlate to 100% CPU usage.
- Investigate if my code is causing the stall, as far as I can tell there is no correlation between a stall and the grain call. It feels like work is queued to be run, but the TaskScheduler/Thread is blocked
- Run through the Orleans calls on the stack, everything runs/returns very fast.
Things I've tried
- Increase core/ram provisions for VMs,
- Didn't help because I am <10% CPU <50% RAM
- Changing to .NET Framework 4.7.1
- This helps, so does this mean that .NET Core handles threads/locks differently?
- If Framework is handling blocked/stalled thread differently, it might explain it.
- Upgrading to
orleans-2.0.0-ci.20180417.4which is post #3792- This seems to of fixed/masked the problem. The insight I gathered is that it is a work stealing pool.
- Work stealing leads me to think the blocked/stalled thread is handled better
We do get similar issues as @DarkCow had explained as well. Especially timeouts which doesnt get resolved in 30sec, one major thing we had observed is when there are warnings of Queue wait time of xxx start adding up, things start slowing down and timing out.
Our setup
- AWS EC2 instances (8x)
- 3 clusters for each environment (dev, staging, prod)
- Dynamo Db for persistence state
- Persistent Streams are on DynamoDb as well (we are changing this to SmS on next deploy to test it out)
- We have 4 apps using orleans
- 4-8 silo instances (not all apps are the same)
- Currently using Docker Swarm (kubi soon)
- Docker base image for silo is
microsoft/dotnet:2.0-runtimewhich is Linux - Running on .NET Core 2
- Orleans version 2.0.0-rc2
Observations/info
- Our CPU usage are quite low <15%
- Our network in/out seems a bit high (and most of the time on a particular node is ~2.5x higher, and 2 seems to have no load at all)
- We have 4 apps, most of them get the same issue (especially 2 of them which have higher load)
- All environments get the same problems, fortunately prod seems to be more stable - instance types are bigger 1 level bigger
- We dont have too many consumers yet (so requests arent high)
- We do need to reboot at least once weekly especially on 2 specific apps (on prod)
- We have alerts for
Queue wait time oflog warning, and when that gets triggered, generally we need to reboot or things get slowing down - Timeouts doesnt seem to happen only in our grains but also on
PubSubRendezvousGrain
PubSubRendezvousGrain - Timeout exception log

PubSubRendezvousGrain - Queue wait time warning log

Machine network monitoring

Just to bring this in here as suggested in gitter, we have been experiencing these timeouts for a while now: https://github.com/dotnet/orleans/issues/4060
To recap:
8 VMs
1 silo/1 client on each
Client pulls from MSMQ, hardens to file, pushes to grain in silo and awaits processing, deletes file
Clients randomly 'stop' (anywhere from 1-10 days after startup) being able to talk to silos and throw Response did not arrive on time errors
Clients don't all stop at the same time but when the first one stops, all others usually stop within 12 hours
This sometimes happens sporadically from within orleans itself (silo to silo), we can see this when running as a console app.
One of our infrastructure guys mentioned it may be network related in that something isn't being cleaned up/released properly. Whether that's ports or what I'm not sure.
Is there something we can do to provide you more data?
I'm catching up with this thread.
Just to make sure. What level of logging are you running Orleans at. We kind of assume that it's normally Info and Debug is only used during development/testing and only for investigations.
I can tell that all our load tests currently run on full .NET Framework, not on .NET Core. We are going to get to running on .NET Core, but it'll take us some time. That's one variable I see that seems to be consistently different from our test environment.
If you could share memory dumps from silos in the "slow" state, that might provide additional insight.
Until a few days ago I was using Info level, but then I changed it to Warning, because Info does not provide that much helpful information and generates a lot of noise.
@SebastianStehle @DarkCow @stephenlautier do you have log files which you're able to share with us? Above you mentioned that 12h is the point at which this happens, @DarkCow - is it suspiciously close to the 12 hour mark or is that a rough estimate?
A memory dump from a slow/stalled process may also prove useful.
I have now been running orleans-2.0.0-ci.20180417.4 which is post #3792 for ~2 weeks and the problem is solved or masked. But I will revert the staging environment back to the worst case scenario which was Orleans 2.0.0 && .NET core 2.0 Will be back with data hopefully by Thursday.
@ReubenBond There is no correlation between time. Just averages out to every 12 hours I had to restart my system.
@sergeybykov I have noticed that the problem is solved/masked in .net framework over .net core.
We'll prioritize load testing on .NET Core higher to try to repro this in house. In the meantime, any relevant logs and memory dumps would be very helpful.
The longer the running time, the higher this value will be. When it reaches 30 or so, this problem will occur. The initial time is only about 0.3.

I experienced the same, especially methods like GetTotalActivationCount() are super slow.
I wonder if this is dashboard related? Are people experiencing this without the dashboard enabled?
@richorama we dont have the dashboard installed, so its not related
@sergeybykov @ReubenBond How is this problem internal test? Our system is so urgent on the Internet now. Is there any plan to solve this problem?
@aqa510415008 if the situation is urgent, would you consider trying to use a nightly build from https://dotnet.myget.org/gallery/orleans-ci? @DarkCow has reported that the issue does not appear to affect the nightly builds.
If you are able to help by providing logs or a memory dump then that may help us resolve this sooner.
I ran the TestHost project in the OrleansDashboard project overnight. It's an Orleans 2.0.0, 3 silo local cluster with memory providers, running on an i7 quad core with 16GB RAM.
At the start of the run you can see calls to the management grain take <1ms.
After ~11 hours, the management grain is averaging 24ms per request.
It's interesting to note that other grains are not showing signs of running slowly.
Please ignore TestGrain, it has a Task.Sleep to slow it down.
if someone can guide us on how we can get the memory dump that you'd like to have, we can help with that.
Again we are using docker (linux image)