balram rajput
balram rajput

Reputation: 125

Distributed system - How to assign a node ID to each node in distributed system?

How can we assign a unique ID to each node/instance of an application in a distributed environment?

Upvotes: 1

Views: 152

Answers (1)

Stephen C
Stephen C

Reputation: 718678

You could potentially use any of the following:

  • The MAC address of the server when you created the node. MAC addresses are not supposed to be reused / re-assigned to a different server.
  • A random (type 4) UUID. The probability of a type 4 UUID being regenerated is too small to worry about.
  • Any large enough random number generated by a crypto quality PRNG seeded with a decent source of entropy.
  • Anything you want ... in combination with a registry mechanism that ensures that identifiers are not going to be reused.

Presumably, you store each node's id in the persistent state of the node itself so that it can look it up when it restarts. (If not, you could make it the responsibility of the the node launch / relaunch mechanism to tell it.)

Upvotes: 1

Related Questions