Multi-region deployment of Dgraph, role of follower Zeroes

Hi everyone.

I’m trying to deploy Dgraph across two regions (United States and Europe), but I have trouble understanding the role of follower Zeroes in a cluster.

I’m deploying a setup of:

  • 2 Zeroes
  • 2 Alphas

Where each Alpha is a replica of the other (there is one Alpha group), and each region contains 1 Zero and 1 Alpha.

First, in the example at https://dgraph.io/docs/deploy/production-checklist/#ha-setup-6-node-cluster all Alphas belong to the leader Zero. Does that mean the Alpha’s only listen to the leader Zero? Or would, if I query a follower Zero, a local Alpha respond to the follower Zero?

Second, if I post data to a follower Zero, will that be propagated to the leader Zero?

Third, what would happen if I set up 1 Alpha to listen to the leader Zero, and 1 Alpha to the follower Zero? For example:

dgraph zero --replicas=3 --idx=1 --my=zero1:5080
dgraph zero --replicas=3 --idx=2 --my=zero2:5080 --peer=zero1:5080
dgraph alpha --my=alpha1:7080 --zero=zero1:7080
dgraph alpha --my=alpha2:7080 --zero=zero2:7080

Thanks,
Martin

1 Like

Hi @martinthenth,

Thanks for your post.

Quoting from Dgraph paper at Dgraph Whitepapers: In-Depth Insights and Analysis,
Dgraph consists of Zeros and Alphas, each representing a group that they are serving. Each group is a Raft Cluster of an odd number of members. Zeros store and propagate metadata about the cluster while Alphas store user data.
As mentioned in Consistent Replication section of Cluster Setup - Deploy, it is recommended to use odd number of zeros and alphas for maintaining consensus among the group.

Alphas listen to Zero group (the Raft cluster) as a whole. In a Raft cluster, every write is consistently replicated to the group. No matter which zero you query, you will get the same response.

Quoting from paper, Zeros store and propagate metadata about the cluster while Alphas store user data.
In case data is posted to a follower Alpha, it will be propagated and replicated to leader Alpha.

The --peer parameter is used to point out the Zero cluster to the Alpha. In the given example, as both zeros belong to the same Zero group (Raft cluster), the result will be same as setting both Alphas to the leader Zero.

As long as you set Alpha’s --zero flag to a Zero in the cluster, it first connect to that Zero and then make a connection to the current Zero leader for updates.

You can also set multiple Zero addresses for that option:

dgraph alpha [other flags] --zero zero1:7080,zero2:7080,zero3:7080

In which case, it will try to connect with any one of these Zeros to connect with the cluster and, once connected, will make a connection with the current Zero leader.

For Zeros, many of its admin commands require them to be done on the leader.

1 Like

Okay this clears up a lot on how Zeroes work together in a cluster. I will add a third Alpha and Zero as the documentation suggests. Thanks Rajas and Daniel!

1 Like