Search code examples
javaserveruniqueidentifier

Generate unique ID across multiple independent servers


I have a system that has 4 servers and each server has its own .war file that hosts on it. Each time the user make calls for a particular function the server should generate a unique id. At a given point there may be hundreds of active instances from all the four servers.

Is there any way to generate id in each server that is totally unique and not generated by the other server?


Solution

  • You may use the UUID. This is an defined format for these universal identifiers. I used it when I had multiple Servers. Or you use a combination of time, a random number and some system-specific data like IP, MAC...