Dgraph Node Type | gRPC-internal-private | gRPC-external-private | gRPC-external-public | HTTP-external-private | HTTP-external-public |
---|---|---|---|---|---|
zero | 50801 | 50801 | 60802 | ||
alpha | 7080 | 9080 | 8080 | ||
ratel | 8000 |
external-public
ports for open access by Dgraph clients, and
configure the gRPC-internal ports for open access by the cluster nodes.
Ratel UI accesses Dgraph Alpha on the HTTP-external-public port
(which
defaults to localhost:8080) and can be configured to talk to a remote Dgraph
cluster. This way you can run Ratel on your local machine and point to a remote
cluster. But, if you are deploying Ratel along with Dgraph cluster, then you may
have to expose port 8000 to the public.
Port Offset To make it easier for users to set up a cluster, Dgraph has
default values for the ports used by Dgraph nodes. To support multiple nodes
running on a single machine or VM, you can set a node to use different ports
using an offset (using the command option --port_offset
). This command
increments the actual ports used by the node by the offset value provided. You
can also use port offsets when starting multiple Dgraph Zero nodes in a
development environment.
For example, when a user runs Dgraph Alpha with the --port_offset 2
setting,
then the Alpha node binds to port 7082 (gRPC-internal-private
), 8082
(HTTP-external-public
) and 9082 (gRPC-external-public
), respectively.
Ratel UI by default listens on port 8000. You can use the -port
flag to
configure it to listen on any other port.
--raft
superflag’s idx
option, and passing the address of any healthy Dgraph
Zero instance using the --peer
flag.
To run three replicas for the Alpha nodes, set --replicas=3
. Each time a new
Alpha node is added, the Zero node checks the existing groups and assign them as
appropriate.
--raft
superflag’s idx
option, or you can leave that flag empty, and the
Zero node assigns an id to the Alpha node. This id persists in the write-ahead
log, so be careful not to delete it.
The new Alpha nodes automatically detect each other by communicating with Dgraph
Zero and establish connections to each other. If you don’t have a proxy or load
balancer for the Zero nodes, you can provide a list of Zero node addresses for
Alpha nodes to use at startup with the --zero
flag. The Alpha node tries to
connect to one of the Zero nodes starting from the first Zero node address in
the list. For example: --zero=zero1,zero2,zero3
where zero1
is the
host:port
of a Zero instance.
Typically, a Zero node would first attempt to replicate a group, by assigning a
new Alpha node to run the same group previously assigned to another. After the
group has been replicated per the --replicas
flag, Dgraph Zero creates a new
group.
Over time, the data is evenly split across all of the groups. So, it’s important
to ensure that the number of Alpha nodes is a multiple of the replication
setting. For example, if you set --replicas=3
in for a Zero node, and then run
three Alpha nodes for no sharding, but 3x replication. Or, if you run six Alpha
nodes, sharding the data into two groups, with 3x replication.