phoenixframework / firenest

Apache License 2.0
270 stars 14 forks source link

Require a channel when sending messages in the topology #4

Closed josevalim closed 5 years ago

josevalim commented 6 years ago

See https://arxiv.org/pdf/1802.02652.pdf.

bitwalker commented 6 years ago

Since a channel will be required, how do you plan to expose that configuration? Is the plan to point people to Partisan or provide an alternative as part of this project? Strictly speaking, this is really more of an optional thing rather than required, since the default Erlang distribution channel is sufficient for small clusters - I think it's only in large clusters where congestion becomes a problem.

josevalim commented 6 years ago

We want to change the Firenest.Topology API so that a channel is expected as argument when sending messages. This will allow us to use Partisan efficiently or allow someone to implement better multiplexing than the disterl that uses a single connection.

bitwalker commented 6 years ago

That makes sense, but what is the channel abstraction? As far as I'm aware, there is nothing for distributed Erlang, it's just baked into the kernel modules (primarily :rpc) - is Firenest planning on exposing a behavior or protocol for other libraries to standardize on, or is there one already available that I'm not aware of? I didn't see anything like that in Partisan, but I skimmed through, so I may have missed it.

josevalim commented 6 years ago

The name "channel" is confusing in our context, so we will need something better. The idea though is to tag messages and we provide ordering guarantee only for messages with the same tag. This allows us to open up multiple connections between nodes. More info on section 3.3.2 in the paper.

bitwalker commented 6 years ago

I think it's good terminology, but yeah, in the context of Phoenix it will certainly be confusing.

In any case, I think I get it now, in Firenest.Topology.Erlang, the channel tag would be ignored, but for a topology based on Partisan, the tag would be passed through to the Partisan API, is that correct? I'm assuming the channel tag would be optional when sending messages using the Firenest API, but required by Firenest.Topology implementations, since that appears to be how Partisan works as well (non-tagged messages just use a default channel).

josevalim commented 6 years ago

Yes, precisely. :+1:

Qqwy commented 6 years ago

Some other names instead of "Channel":

Accurate but probably bad because of its use in different (but related) contexts:

Maybe better; all of these attempt to capture the 'messages are ordered when having(/being on) the same X':

josevalim commented 6 years ago

I think I would call it a partition and probably force them to be integers. If we don’t want to impose integers, then I would say the argument is always hashed. --

José Valimwww.plataformatec.com.br http://www.plataformatec.com.br/Founder and Director of R&D

Qqwy commented 6 years ago

I think I would call it a partition and probably force them to be integers.

Having now read the Partisan paper thoroughly, I disagree with both of these proposals because:

josevalim commented 6 years ago

@Qqwy right. so we can just allow them to be any term, which we will hash and send in the available number of underlying connections.

michalmuskala commented 6 years ago

I'm not sure we want to do hashing - I think the goal is to send a particular message on a particular connection and not just have a pool where you multiplex messages.