suppose genstage have one producer and many consumer for push notification in a chat application and each consumer subscribe that one producer. now tell me, after subscribing that single producer, consumer will ask notification from producer. how producer will send my group notification because all group are sending notifications to only that single producer?
I think notifications does not have the same meaning here…
In Genstage, the demand comes from the consumer, the producer is just delivering data. It never goes the other way around.
see this blog, in this blog they say they have one producer per machine and many consumers and consumer subscribe certain producer and when consumer receive this handle_subscribe then consumer use GenStage.ask and when producer receive in handle_demand, it do nothing according to blog.
suppose in a chat system when a channel have to send notification it use this GCM.PushCollector.push function to send to producer and then in handle_cast, it send to all subscriber consumers.
now i want to know how producer determing which notification it have to send to which consumer, if it send all notifications to all subscribe consumers then it will increase overload?
There is no such thing for the producer. The producer cannot select which consumer will handle an event. However the dispatcher behaviour might be able to route events to certain consumers: GenStage.BroadcastDispatcher — gen_stage v1.2.1
This will make things more complicated as back pressure will still be applied globally. So if one specific type of event slows down I think processing of all events will slow down. Even if not the other option would be a growing buffer in the dispatcher, which also eventually becomes a problem.
ok give me solution,
in discord blog it says, one producer per machine that means many consumers subscribe same producer.
then how discord producer send notifications to certain consumer if producer does not filter according to blog(i mean how discord producer rotate notification to crrtain user)?
That expects they require a certain consumer to handle the notification in the first place. At best the genstage consumers don’t care which notification they handle – they just handle whatever they get. Looking at the blog post that seems to be the case for discord as well.
one last question,
if i am member of 25 groups then i should have to start 25 consumers?