-
Notifications
You must be signed in to change notification settings - Fork 48
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
"Memory leak" in PubSub pattern #36
Comments
Yes, the messages in the recv_queue should be consumed manually. If we don't do that the message will accumulate. Then it will be killed by the Erlang runtime. |
Feel free to hack on this repo too. I'll gladly add you as a maintainer. |
Have this problem solved? |
No. Eventually I've started using the inner parts of this code so that the process management is totally handled by an external module. Chumak is being used just as a ZeroMQ serializer ATM. |
Are you saying the high-water mark is not implemented for PUBSUB? |
As fair as I remember, no. At the same time, there's a long while I don't work with it, so there is a chance I'm wrong. But if I'm right, and you decide to implement it, keep in mind these losses would have proper metrics in place, so the user knows when the app is losing events. The code I've mentioned above wraps the inner functions in a particular GenServer that blocks the publisher. So the events are lost at the publisher side, that didn't have proper metrics, so we never knew if we were losing events neither how much we were losing. |
In terms of modeling, I would say that adopting a behavior is better instead of having a separated process to receive events. Then you leave the option to enqueue (up to a limit) or blocking the publisher to the user, instead of choosing one of them in advance. There are use cases for both. |
The |
Here is the chumak’s process tree:
chumak_peer
reads frames fromgen_tcp
in active mode (more specifically{active, once}
, eventually enqueueing messages inrecv_queue
), expecting that{your process}
callschumak:recv
fast enough to consume all of that.If your consumer isn’t capable of handling all messages as they arrive at
chumak_socket
; they will accumulate indefinitely!The text was updated successfully, but these errors were encountered: