I
I
iogurt892016-04-28 08:45:11
Distributed Computing
iogurt89, 2016-04-28 08:45:11

Is UUID really that reliable?

Good afternoon. The Wiki article for UUID says:

The main purpose of UUID is to allow distributed systems to uniquely identify information without a clearing house. Thus, anyone can create a UUID and use it to identify something with a reasonable level of confidence that the given identifier will inadvertently never be used for something else. Therefore, information tagged with a UUID can be placed later in a shared database without the need to resolve name conflicts.

In my situation, I need to generate identifiers for messages in the messenger. With active correspondence, each user can send about a hundred messages. The people who will use this messenger will be at least 500 people (the size of the company in which it will be used). Is it really possible to use UUID in such a situation and not be afraid that IDs will be repeated?
Please share your experience of using UUID in real, more or less large projects.
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
G
GavriKos, 2016-04-28
@iogurt89

In your case, it is much easier to generate an ID based on the user's nickname in the chat (his ID number in the database, for short) + timestamp with microsecond precision. Guaranteed uniqueness.

V
Vasily, 2016-04-28
@Applez

In general, there is a standard on UUID that specifies the requirements, if they satisfy you, then you can safely use it. RFC4122

R
rostislaved, 2020-01-16
@rostislaved

"The total number of unique UUID keys (excluding versions) is 2^128 = 256^16, or about 3.4 × 10^38. This means that by generating 1 trillion keys every nanosecond, it will take only 10 billion years to sort through all possible values . "(c) wiki
In your case, 100 posts * 500 people = 5*10^4 per day, then:
P1 = 1 / (3.4 × 10^38) - the probability of getting one specific value
P_day = ( 5*10^4) * P1 = 1.5 * 10^-34 - the probability of getting one certain value in 1 day
P_year = 365 * P_day = 5.5 * 10^-32 - the probability of meeting a certain value in 1 year

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question