Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk7 min

UUIDv7: The Idea Behind a High-Throughput Java Generator

UUIDv7 places a Unix millisecond timestamp in its leading 48 bits, so IDs sort roughly by creation time. Strict ordering, clock rollback handling, and throughput depend on each Java generator's design.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

UUIDv7 puts a Unix millisecond timestamp in the most significant 48 bits of the identifier, so IDs sort roughly by creation time. That prefix is the whole standard-level idea. Whether a Java generator also produces strictly increasing IDs, how it behaves when the clock stalls or moves backward, and how fast it runs are decisions made by each implementation, and they trade off against one another.

What UUIDv7 specifies

RFC 9562, published by the IETF in May 2024, defines UUIDv7 as a time-ordered identifier. Its timestamp is the number of Unix milliseconds since midnight on 1 January 1970 UTC, with leap seconds excluded. That value occupies the 48 most significant bits of the 128-bit UUID.

The rest of the identifier breaks down as follows:

Bits Field Purpose
48 Unix timestamp in milliseconds Places the ID on a time axis; the most significant part of the value
4 Version Identifies the UUID as version 7
2 Variant Identifies the RFC 9562 layout
74 Random, or optional sub-millisecond fraction and counter, plus random bits Separates IDs created within the same millisecond

The 74 bits after the version and variant fields are where implementations differ. The standard allows them to be filled with random bits. It also allows an implementation to spend part of that space on an optional sub-millisecond timestamp fraction (up to 12 bits), then on an optional counter that has been carefully seeded, and to fill any remaining space with random bits.

The standard also says implementations SHOULD use UUIDv7 instead of UUIDv1 and UUIDv6 when possible. That is the one normative recommendation the RFC makes about choosing a version, and it applies whatever generator you use.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What “time-ordered” does and does not guarantee

Because the timestamp is the leading field, sorting UUIDv7 values as binary or as text generally sorts them by creation millisecond. This makes them useful as database primary keys or index keys: new rows append near the end of a B-tree-style index rather than landing at random positions. Those benefits come from the timestamp prefix alone.

Three limits matter in practice:

  • Same-millisecond order is not fixed by the format. Two IDs created in the same millisecond may sort either way unless the generator adds a sub-millisecond field or counter and keeps it monotonic.
  • Clock adjustments can break the sequence. If the wall clock steps backward, a generator that relies only on the timestamp can produce a value that sorts before earlier ones.
  • Separate machines have no shared order. IDs produced on different hosts are ordered by their clocks, which may be skewed. Time order across a cluster is approximate, not a global chronology.

So “time-ordered” is the accurate description. “Monotonic” and “strictly chronological” are claims that a specific generator has to document and deliver.

How Java generators handle ordering

The UUIDv7 layout leaves a designer several choices, and the Java implementations below illustrate them. They are examples drawn from each project’s documentation, not a complete ranking of Java UUID libraries. Where a project’s documentation did not address an axis, the table says so.

Confined state with strict increase per instance

The robsonkades UUIDv7 project documents a generator whose instances are not thread-safe. They should be confined to one thread or protected by external synchronization. Within one instance, the documentation describes strictly increasing values, including within the same millisecond and across wall-clock rollback. The project also offers batch-fill methods that write binary representations into caller-provided arrays, which reduces per-ID allocation when many IDs are needed at once. These behaviors are claims in the project’s own documentation and should be checked against the release you adopt.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Best-effort monotonicity for shared use

Apache Spark’s JavaDoc describes a UUID generator that embeds a 48-bit Unix-millisecond timestamp and random bits. It states that same-millisecond ordering and clock adjustments can prevent strict monotonicity, and that this trade-off is intentional. The stated reason is to avoid throughput degradation and thread contention. The design accepts that order is only approximate in exchange for not coordinating callers.

Synchronized counter for strict order

The Block Java README describes a MonotonicUUIDv7 implementation that uses a synchronized counter to keep IDs strictly ordered within the same millisecond. Strict order comes at the cost of coordination between threads. How much that costs under your workload has to be measured, because the README does not establish a throughput figure for the target use.

General-purpose UUID library

UUID Creator documents support for standard UUID versions through UUIDv7. Support for a version is a convenience, not evidence of a particular ordering or performance profile. Read the current version’s API and guarantee notes before assuming anything beyond the presence of the version.

Comparison across the four approaches

Implementation (source) Documented ordering State and synchronization Clock rollback Batch API
robsonkades UUIDv7 project Strict increase per instance, including same-millisecond generation Instance not thread-safe; confine to one thread or synchronize externally Documented as preserving strict increase Yes; batch-fill writes binary output into caller arrays
Apache Spark UUID generator (JavaDoc) Best-effort; strict monotonicity not guaranteed Chosen to avoid thread contention; internal state not stated Clock adjustments can prevent strict monotonicity Not stated
Block Java MonotonicUUIDv7 (README) Strict within the same millisecond Synchronized counter Not stated Not stated
UUID Creator (documentation) Not stated for UUIDv7 ordering in the source reviewed Not stated Not stated Not stated

The table shows why a single throughput ranking misleads. A generator that is fast in batch mode on a confined thread may be the wrong choice for a shared service that needs strict order across callers. Choose by the guarantee you need first, then measure.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Clock rollback and counter exhaustion

RFC 9562 says a generator must not knowingly return duplicate values because a counter rolled over. Depending on its requirements, the generator can either signal an error or wait until the clock advances. Both are legitimate. Silently wrapping a counter is not.

When you evaluate a library, check three behaviors explicitly:

  • What happens when more IDs are requested in one millisecond than the counter and random space can represent.
  • Whether the generator blocks, throws, or returns a value when the wall clock moves backward.
  • Whether timestamp precision coarser than a millisecond (for example, a clock that advances in larger steps) can cause repeated timestamps that the generator must compensate for.

Implementations that document “strict increase” typically answer these questions in their own code comments or README. Where a project is silent, treat the behavior as unknown rather than assuming the best case.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Random bits and security

The RFC recommends a cryptographically secure pseudorandom number generator (CSPRNG) when the unpredictability of identifiers matters, for example when IDs appear in URLs or act as unguessable tokens. A generator that uses a fast non-cryptographic source may be perfectly adequate for internal keys and still be wrong for those cases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep two properties separate. Collision resistance means two IDs are unlikely to match. Unguessability means an attacker cannot predict an ID from earlier ones. A UUIDv7 with a timestamp prefix is partly predictable by design, because the leading bits reveal when it was created. Random bits supply the remaining protection, and that protection depends on the quality of the random source. Uniqueness is an engineering property the design makes very likely, not a mathematical guarantee that holds in isolation.

Reading published throughput figures

The robsonkades repository publishes benchmark results measured with JMH 1.37 on Temurin OpenJDK 25.0.3, Windows 11, and an Intel Core i7-13700K. Its setup uses a 1 GiB initial and maximum heap, five one-second warmup iterations, five one-second measurement iterations, and two forks. Contended runs use eight threads. These are the project author’s measurements of the project’s own code and benchmark suite. They have not been independently reproduced, and the author notes that results vary with JVM, CPU topology, entropy provider, and operating-system timer behavior.

Benchmark (robsonkades repository, accessed 2026) Reported result Scope
optimizedFillLongBatch, 256 UUIDs per batch 1.473 billion operations per second; 0.68 ns per UUID Single-thread batch fill on the documented Windows 11, Temurin OpenJDK 25.0.3, Core i7-13700K setup
optimizedFast (per-ID) 248.4 million operations per second; 4.03 ns per UUID Same documented environment, single-item API
contendedOptimizedFast 1.053 billion operations per second at eight threads Same reported platform; contended workload

Two points follow from these figures. First, batch and per-ID results differ by roughly a factor of six in the project’s own numbers, so comparing a batch figure to a single-item figure is a category error. Second, a contended figure reflects the project’s eight-thread workload on one machine, not what your service will sustain on a different JVM or operating system.

A decision checklist for choosing a generator

  1. Decide the ordering you need: time-ordered prefix only, best-effort monotonic, or strict order within a millisecond or per instance.
  2. Decide whether strict order must hold across threads, across instances in one process, or across machines. Across machines, clocks are the limit.
  3. Confirm the state model: thread-confined, shared with synchronization, or shared without coordination. Check whether the instance is documented as thread-safe.
  4. Check clock rollback and counter exhaustion behavior in the documentation for the exact version you will run.
  5. If identifiers must be unguessable, confirm the random source is a CSPRNG.
  6. Choose the return type you need: UUID, string, or binary. Use batch APIs only where the workload creates many IDs at once.
  7. Benchmark the chosen generator on your JVM, hardware, thread count, and allocation profile, and compare the same API shape, such as batch to batch.

Done in that order, the throughput question usually resolves quickly, because most of the options are eliminated by the ordering and state requirements before any benchmark runs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.