Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

Is the transport required to be reliable? #175

Closed
tathougies opened this issue Feb 26, 2021 · 3 comments
Closed

Is the transport required to be reliable? #175

tathougies opened this issue Feb 26, 2021 · 3 comments

Comments

@tathougies
Copy link

The docs seem to use TCP as the transport, but many Raft implementations work in an unordered, unreliable setting as well. Can UDP be used?

@freeekanayaka
Copy link
Contributor

You can deliver whole messages in any order, yes, and this implementation will be just fine with that. However if you simply swap TCP with UDP using the default implementation of the raft_io interface, then you might get partial messages (or any sort of byte rearrangement of the message stream), and that won't work. You'd need to implement your own version of the raft_io interface that is able to tolerate UDP re-arrangements and still deliver whole messages to the core engine (possibly out of order). See also raft.h for the definition of the raft_io interface.

Hope that helps.

@tathougies
Copy link
Author

I suppose my follow up would be if there's a maximum size for the datagram. I would imagine if it's below the link MTU then we wouldn't need to worry about re-arrangement. On the other hand, TCP probably works fine.

@freeekanayaka
Copy link
Contributor

I suppose my follow up would be if there's a maximum size for the datagram. I would imagine if it's below the link MTU then we wouldn't need to worry about re-arrangement. On the other hand, TCP probably works fine.

We wouldn't need to worry about partial messages, correct. But the raft library can't make such a guarantee because the size of (say) AppendEntries messages basically depend on the user's payload.

Note that there's been anecdotal evidence that UDP doesn't make the Raft algorithm any faster in practice. Plus you'll very likely need to re-invent some part of TCP in your UDP-based implementation (e.g. flow control).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants