Java UUID Generation tool concurrency test

Source: Internet
Author: User
Tags file system generator repetition uuid


I. Understanding of UUID



Uuid



Wikipedia, the free encyclopedia



Universal Unique identifier (universally unique Identifier, UUID) is a software construction standard, also for the Free Software Foundation (Open Software Foundation, OSF) organization in the Distributed computing environment (distribut Ed Computing Environment, DCE) is part of the field.



The purpose of UUID is to allow all elements in a distributed system to have unique identifying information, without the need to specify the identification information through the central control. In this way, each person can establish a UUID that does not conflict with others. In such cases, there is no need to consider the name duplication problem when the database is established. The most widely used UUID is Microsoft's globally Unique Identifiers (GUIDs), while other important applications are Linux EXT2/EXT3 file system, Luks encrypted partition area, GNOME, KDE, Mac OS X, and so on. In addition, we can find the implementation in the UUID library in the E2fsprogs package.



[Edit] Definition



A set of UUID, consisting of a string of 16 bytes (also called 16 bytes, or 128 bits) of 16 digits, is the total number of 216 x 8=2128 of the UUID, approximately equal to 3.4 x 1038. That is to say, it takes 10 billion years to run out of all the UUID if 1 trillion UUID is generated per nanosecond.



The standard type of UUID consists of 32 16 digits, which are divided into five segments, in the form of a 8-4-4-4-12 32 characters. Example



550e8400-e29b-41d4-a716-446655440000



The UUID can also be deliberately repeated to denote the same. For example, in Microsoft COM, all components must implement the IUnknown interface by generating a UUID representing the IUnknown. Either the program attempts to access the IUnknown interface in the component, or the component that implements the IUnknown interface, as long as IUnknown is used, it is referenced to the same id:00000000-0000-0000-c000-000000000046.



[Edit] Repeat probability of a random uuid



Of the 128 bits of a randomly generated UUID (such as that generated by the Java.util.UUID Class), 122 bits are randomly generated, 4 bits are used in this version (the ' randomly generated UUID '), and 2 are in their variant (' Leach-salz ') is used. Using the birthday paradox, the probability of the two UUID having the same value is approximately



The following is the probability of collisions after the N-pen uuid is calculated with x=2122:



n Chance
68,719,476,736 = 236 0.0000000000000004 (4 x 10-16)
2,199,023,255,552 = 241 0.0000000000004 (4 x 10-13)
70,368,744,177,664 = 246 0.0000000004 (4 x 10-10)



Compared with the probability of being hit by a meteorite, it is estimated that the probability of a person being hit by a meteorite every year is 17 billion 1[1], that is, the probability is about 0.00000000006 (6 x 10-11), which is equivalent to having a 10 trillion-pointer uuid built into the year and a repetition occurs. In other words, the odds of producing only one repetition per second of 1 billion uuid,100 years are 50%. If everyone on the planet has 600 million uuid each, the chance of a repeat is 50%.



The situation of generating duplicate UUID and causing error is very low, so it is not necessary to consider this problem.



The probability is also related to the quality of the random number generator. To avoid increased repetition, you must generate values by using a false number generator that is grounded in cryptography.



Http://zh.wikipedia.org/zh-cn/UUID





Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.