This repo contains a Go implementation of the broadcast challenge for the Fly.io Gossip Glomers series of distributed systems challenges.
You can install Go 1.20 using gvm with:
gvm install go1.20
gvm use go1.20
Maelstrom is built in Clojure so you'll need to install OpenJDK.
It also provides some plotting and graphing utilities which rely on Graphviz & gnuplot.
If you're using Homebrew, you can install these with this command:
brew install openjdk graphviz gnuplot
You can find more details on the Prerequisites section on the Maelstrom docs. Next, you'll need to download Maelstrom itself. These challenges have been tested against Maelstrom 0.2.3. Download the tarball & unpack it. You can run the maelstrom binary from inside this directory.
From the project's root directory:
go build .
To use the different Maelstrom test commands, please refer to the Fly.io instructions, starting with the Single-Node Broadcast.
# Make sure to replace `~/go/bin/maelstrom-executable`
# with the full path of the executable you built above
./maelstrom test -w broadcast --bin ~/go/bin/maelstrom-broadcast \
--node-count 1 --time-limit 20 --rate 10
Your node should propagate values it sees from broadcast messages to the other nodes in the cluster. It can use the topology passed to your node in the topology message or you can build your own topology.
The simplest approach is to simply send a node's entire data set on every message, however, this is not practical in a real-world system. Instead, try to send data more efficiently as if you were building a real broadcast system.
Values should propagate to all other nodes within a few seconds.
# Make sure to replace `~/go/bin/maelstrom-executable`
# with the full path of the executable you built above
./maelstrom test -w broadcast --bin ~/go/bin/maelstrom-broadcast \
--node-count 5 --time-limit 20 --rate 10
Your node should propagate values it sees from broadcast messages to the other nodes in the cluster—even in the face of network partitions! Values should propagate to all other nodes by the end of the test. Nodes should only return copies of their own local values.
# Make sure to replace `~/go/bin/maelstrom-executable`
# with the full path of the executable you built above
./maelstrom test -w broadcast --bin ~/go/bin/maelstrom-broadcast \
--node-count 5 --time-limit 20 --rate 10 --nemesis partition
# Make sure to replace `~/go/bin/maelstrom-executable`
# with the full path of the executable you built above
./maelstrom test -w broadcast --bin ~/go/bin/maelstrom-broadcast --node-count 25 --time-limit 20 --rate 100 --latency 100
With the same node count of 25 and a message delay of 100ms, your challenge is to achieve the following performance metrics:
- Messages-per-operation is below 20
- Median latency is below 1 second
- Maximum latency is below 2 seconds
# Make sure to replace `~/go/bin/maelstrom-executable`
# with the full path of the executable you built above
./maelstrom test -w broadcast --bin ~/go/bin/maelstrom-broadcast \
--node-count 25 --time-limit 20 --rate 100 --latency 100