In order to celebrate the new beta release of Rust, and as part of reporting requirements for my class, I'm happy to write to you regarding hoverbear/raft!
A Recap
In January, 2015, a undergraduate (me) at the University of Victoria set out on a quest to implement the Raft Consensus Algorithm in Rust, an experimental language in shepherded by Mozilla Research.
If you don't know what Raft is, please take a look at the secret lives of data. If you don't know what Rust is, please feel encouraged to follow along at the intro.
Back in february I had a first prototype working. It was a partial implementation and some subtle logic flaws have been found in the reworking of the code.
You can play with the very first prototype here updated for a recent nightly.
Where We're Heading
With the help of Dan Burkert several dramatic architecture changes have occured.
Summarily, the second prototype builds from the first in the following ways:
- The mio Asynchronous Event Loop backs the library, providing
it with event driven sockets and timers. This removes the
loop {}
and reduces demands on the system by using things likeepoll
. - Communication is over TCP, as opposed to UDP in the first prototype. It was determined that the additional costs of TCP were worth its benefits provided connections to other nodes could be maintained for multiple communications. This improves reliability of communication, ease of understanding, and opens the door for encrypted communication at a later date.
- For more efficient communication, Cap'n Proto is used to facilitate communication between nodes. This dramatically reduces the amount of data which needs to be sent compared to the first prototype, which uses JSON.
- The Replicated Log is abstracted from the library allowing the client to provide their own backing storage for the log in the fashion of their choosing.
- A
Raft
type is now provided to the consuming application which dramatically simplifies client communication with the cluster. As a result of this, all client requests require a network trip, but in the vast majority of cases, this was required regardless, since all client requests must go to the leader. - The State Machine abstraction has been improved in order to facilitate more useful consumption of the library. The first prototype's interface was determined to be insufficient to provide things like Log Compaction, an optional feature of Raft, in the future.
This changes are still not done, as they have required a considerable amount of work, both on our code and on upstream libraries.
As a result of this project, several pull requests to upstream projects have been created and merged.
Merged pull requests by Dan Burkert:
- impl
::std::error::Error
forcapnp::Error
- Implement
std::error::Error
forstd::sync::mpsc
error types
Merged pull requests by Ana Hobden:
- Move to
&mut s[..]
syntax - Update
std::error
example - Add
Read
andWrite
toRingBuf
- Add docs for
NonBlock<TcpListener>::accept()
- Implement
collect()
- Derive not Deriving
Thanks
At this time I'd like to personally extend thanks to the following people:
- David Renshaw (@dwrensha)
- Carl Lerche (@carllerche)
- Dan Burkert (@danburkert)
For their professionalism, mentorship, and community involvement. One of my favorite things about the Rust community is just how great it is. Stop by on IRC sometime!
I'm having a tremendous amount of fun on this project and I'm learning so much. I can't wait to wrap up my semester to get back to work on Raft!
You can get involved with Raft here. Or join the Reddit discussion here.