# Efficient Distributed Unique Timestamp Identifier Generation

DevFeed: [Efficient Distributed Unique Timestamp Identifier Generation](<https://devfeed.tech/articles/efficient-distributed-unique-timestamp-identifier-generation-30742.md>)

Original publisher: [Read original article](<http://blog.vanillajava.blog/2024/12/efficient-distributed-unique-timestamp.html>)

Author: Peter Lawrey (noreply@blogger.com)

Published: 2024-12-08T19:51:00Z

Content type: tutorial

Language: en

Sources: [Vanilla Java](<https://devfeed.tech/sources/vanilla-java.md>)

Topics: [identifier](<https://devfeed.tech/topics/identifier.md>), [systems](<https://devfeed.tech/topics/systems.md>), [Microservice](<https://devfeed.tech/topics/microservice.md>), [Concurrency](<https://devfeed.tech/topics/concurrency.md>), [ordering](<https://devfeed.tech/topics/ordering.md>), [Latency](<https://devfeed.tech/topics/latency.md>)

Tags: [benchmarks](<https://devfeed.tech/tags/benchmarks.md>), [concurrent](<https://devfeed.tech/tags/concurrent.md>), [distributed](<https://devfeed.tech/tags/distributed.md>), [identifier](<https://devfeed.tech/tags/identifier.md>), [latency](<https://devfeed.tech/tags/latency.md>), [microservices](<https://devfeed.tech/tags/microservices.md>), [ordering](<https://devfeed.tech/tags/ordering.md>), [performance](<https://devfeed.tech/tags/performance.md>), [precision](<https://devfeed.tech/tags/precision.md>), [unique](<https://devfeed.tech/tags/unique.md>)

## AI overview

The article presents a distributed identifier scheme that embeds a host identifier into a nanosecond-resolution timestamp. It describes the resulting 64-bit identifiers as globally unique, human-readable, chronologically sortable, and suitable for high-concurrency, latency-sensitive systems.

## Source excerpt

Distributed unique timestamp identifiers provide a powerful means of generating globally unique, human-readable 64-bit values at sub-microsecond speeds. By embedding a host identifier directly into a nanosecond-resolution timestamp, you gain a simple, chronologically sortable, and intuitive scheme for correlating events across multiple hosts. This approach offers significant benefits in latency-sensitive systems where even small delays can become expensive at scale. Introduction In a world of horizontally scaled microservices, ensuring that each event or message receives a unique identifier across multiple machines can be challenging. Traditional approaches often rely on UUIDs, which--while easy to use--lack intuitive readability and can be relatively expensive to generate in ultra-low-latency scenarios. Our solution builds upon nanosecond-resolution timestamps combined with a host identifier embedded directly into the lower-order digits of the timestamp. This technique, inspired by previous work on system-wide unique nanosecond timestamps, creates identifiers that are compact, human-interpretable, and extremely fast to produce. In essence, we treat time itself as the source of uniqueness. By carefully structuring the timestamp and assigning a unique hostId per machine (or per logical partition), we can scale to produce up to one billion unique 64-bit identifiers per second. These identifiers repeat only after centuries, making them suitable for long-running systems and distributed architectures that demand both precision and high performance. Concurrent identifier generation in a distributed system In distributed environments, colliding identifiers can lead to data corruption, misrouted requests, or difficulty in debugging. Although UUIDs solve uniqueness issues, they do not inherently convey temporal ordering or machine origin. More subtle forms of identifiers, such as database sequence numbers or custom counters, often need to be more convenient when synchronising