orleans icon indicating copy to clipboard operation
orleans copied to clipboard

Stream AddSubscriber/RemoveSubscriber invocations on producer grain shouldn't keep it alive

Open shlomiw opened this issue 7 years ago • 8 comments

Hi,

I've found a major 'grains-leak' in my cluster.

The reason: Short lived grains which produced events on an active stream (SMS). This stream is being actively subscribed/unsubscribed by consumers, that in turns invokes AddSubscriber/RemoveSubscriber on the producer grains. These invocations are delaying the deactivation of these grains.

This is very unexpected behaviour. These are indirect invocations that the developers shouldn't be aware of.

Workaround: manually invoke DeactivateOnIdle.

I believe that AddSubscriber/RemoveSubscriber shouldn't affect the GC collection time.

Moreover, I think grains should have an attribute on methods stating they're not affecting the GC time. It can be useful in some cases. See SkipUpdateLastAccess in Orbit https://github.com/orbit/orbit/wiki/Concepts%3A-Useful-Annotations (thank to @SebastianStehle #5281).

Big thanks to @seniorquico and @jason-bragg which helped me a lot in gitter to figure it out. @seniorquico actually took his time to write a test case which helped clarifying! The Orleans community is amazing!

shlomiw avatar Apr 03 '19 19:04 shlomiw

Update - the 'workaround' fix greatly reduced our Production silos memory, amount of grains and grain response latency during high loads! :muscle:

I believe that solving this issue is important. Thanks!

shlomiw avatar Apr 14 '19 09:04 shlomiw

@shlomiw Glad to hear. What exactly was the workaround that you applied?

sergeybykov avatar Apr 19 '19 18:04 sergeybykov

I have a maintenance timer which manually invokes DeactivateOnIdle when the grain is no longer required. This removes the grain as a producer of the SMS stream (at PubSubRendezvousGrain). So it won’t receive AddSubscriber/RemoveSubscriber calls anymore.

shlomiw avatar Apr 20 '19 20:04 shlomiw

Yeah this behavior is by design at the moment, But I can see how inconvenient it can be. Maybe it can be included in streaming 3.0 as one of the problems Streaming 3.0 can solve. @jason-bragg

Move it into backlog if this is OK.

xiazen avatar May 08 '19 21:05 xiazen

@xiazen - where can I see info about Streaming 3.0? I am curious :)

shlomiw avatar May 09 '19 19:05 shlomiw

it is in people's head at the moment ;p. we are so bad at documenting. Maybe @jason-bragg will be interested in put some text out.

xiazen avatar May 09 '19 21:05 xiazen

We are marking this issue as stale due to the lack of activity in the past six months. If there is no further activity within two weeks, this issue will be closed. You can always create a new issue based on the guidelines provided in our pinned announcement.

ghost avatar Dec 11 '21 01:12 ghost

This issue has been marked stale for the past 30 and is being closed due to lack of activity.

ghost avatar Mar 05 '22 02:03 ghost