Most distrubution system will select UUID as the object indentifier. But the length of UUID would be 36 chars and in Java it need 72 bytes persist and it was randomly and no-sequential inside so it will hurt the search/lookup within storage. Even some system provide some sequential UUID support, but it binding with system (specialization). So here I want post new way replace that:

 

The new ID will be includes the following parts:

1. Sever identifier

2. Component identifier

3. Thread identifier    (need consider thread group | thread pool either)

4. Time          (it need be judged by your system loads, seconds, milliseconds, etc)

 

Note: Time should be consider centralized synchronized. Otherwise it's not universal unique. Please refer:

http://community.jboss.org/people/andy.song/blog/2010/12/09/the-time-of-your-machine-can-be-trust

 

For examples:

1                   2                        111           6183640443687

Sever           Component           Thread      NanoTime

 

So totoal 19 bits, and its numeric values. And in general situation is has sequence, so use that kinds of id will improve a lot your system performance.

 

It's not new, Twitter current will leverage that ideas. One of their engineer open source that library (snowflake) in:

https://github.com/twitter/snowflake/tree/1cd0af14db9efa7972a9ed605661a7b70962914a/src