In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Today, I would like to talk to you about what the five common distributed ID are, which many people may not know. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something from this article.
It is believed that everyone can come into contact with all kinds of ID every day in the business system of the Internet, such as payment ID, refund ID and so on. Today, the editor will take stock of five kinds of distributed ID.
1. UUID
The standard form of UUID (Universally Unique Identifier) consists of 32 hexadecimal digits, divided into five segments by hyphens and 36 characters in the form of 8-4-4-4-12, for example: 550e8400-e29b-41d4-a716-446655440000. so far, there are five ways to generate UUID in the industry.
Advantages of UUID: very high performance: locally generated, no network consumption.
Disadvantages of UUID:
Not easy to store: UUID is too long, 16 bytes and 128bits, usually expressed as a 36-length string, which is not suitable for many scenarios.
Information insecurity: algorithms that generate UUID based on MAC addresses may cause MAC address leaks, a vulnerability that has been used to find the location of the maker of the Melissa virus.
When ID is used as a primary key, there will be some problems in a specific environment. For example, in the case of DB primary key, UUID is very unsuitable. MySQL officials clearly recommend that the primary key should be as short as possible. The 36-character UUID does not meet the requirements. UUID is also disadvantageous to the MySQL index. If it is the primary key of the database, the disorder of UUID under the InnoDB engine may cause frequent changes in data location and seriously affect performance.
II. Snowflake
I'm not going to introduce snowflake. I'll just talk about its advantages:
The number of milliseconds is high, the self-increasing sequence is low, and the whole ID is increasing.
Do not rely on databases and other third-party systems, deployed in the way of services, higher stability, the performance of generating ID is also very high.
Bit bits can be allocated according to their own business characteristics, which is very flexible.
Disadvantages:
Strongly dependent on the machine clock, if the clock on the machine is dialed back, it will cause the number to be duplicated or the service will be unavailable.
MongDB's ObjectID can be counted as a method similar to snowflake, with a total of 12 bytes through "time + machine code + pid+inc" and finally identified as a 24-length hexadecimal character by the way of 4: 3: 2: 3.
3. Meituan's open source Leaf
Support the generation strategy of many different patterns
Number segment mode: this mode requires the establishment of a DB table, and a special service is required to provide the interface to obtain id. There is network delay.
Snowflake pattern: in order to pursue higher performance, it is necessary to deploy Leaf services through RPC Server, which only needs to introduce the package of leaf-core and encapsulate the API that generates ID into the specified RPC framework.
The disadvantage may be that it is relatively complex.
IV. Sharding-jdbc
Sharding-jdbc is an open source primary key generation component. Its characteristic is easy to use, can specify workerId or not, directly through the way of jar can be introduced. As you can see by its name, it needs DB support.
5. Uid-generator
Uid-generator is a distributed ID generator open source by Baidu. Need to build DB table, need to have a special service to provide the interface to obtain id, there is network delay.
After reading the above, do you have any further understanding of what are the five common distributed ID? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.