Looking for breakthrough ideas for innovation challenges? Try Patsnap Eureka!

Method for generating unique ID in distributed system

A distributed system, the only technology, applied in the field of distributed systems, can solve the problems of IDs are not sorted, cannot meet the needs of multi-agent deployment, and has a single point of risk, etc.

Inactive Publication Date: 2017-12-08
成都数联铭品科技有限公司
View PDF3 Cites 18 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

[0003] Existing typical solutions include: 1. Database self-growth sequence or field; method: use database, unique in the entire database, advantages: simple, convenient, acceptable performance, natural sorting of IDs, disadvantages: single point risk, when the amount of data exceeds the database When accessing capabilities, you will encounter expansion and performance bottlenecks
2. UUID, method: directly call the UUID function or generate a third-party library, advantages: simple and convenient; disadvantages: IDs are not sorted and have no business relevance
3. snowflake algorithm: method: use 41bit as the number of milliseconds, 10bit as the ID of the machine (5 bits are the data center, 5 bits of the machine ID), 12bit as the serial number within milliseconds (meaning that each node is in every millisecond It can generate 4096 IDs), and there is a sign bit at the end, which is always 0; advantages: fast speed, high concurrency, and scalability; disadvantages: since there are only 10bit machine IDs, it cannot meet the requirements of multi-agent deployment, and can only be used as a separate ID generation service, so that the application requesting the ID depends on the external network and cannot have enough business information
[0004] The current unique ID generation scheme generally has the following serious problems: high resource consumption, the scheme itself relies on external storage devices, resulting in a large number of IO
There is no business correlation, the service generates ID uniformly, and the application requesting the ID has the dependence of the external network, and cannot be optimized and expanded according to its own business needs
[0005] When the application scenario is strongly related to the business, such as when it needs to be deployed together with the business application, we need the generated ID to carry the corresponding information as much as possible; do not interact with the external network, the unique ID is directly generated locally, and has low resource consumption. When generating functions such as fast generation speed, high concurrency, and high scalability, the existing methods for generating unique IDs cannot meet the requirements

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • Method for generating unique ID in distributed system
  • Method for generating unique ID in distributed system
  • Method for generating unique ID in distributed system

Examples

Experimental program
Comparison scheme
Effect test

Embodiment 1

[0044] Suppose the APPID number on a host is 14678502, the host IP address is 192.132.2.65; the timestamp is 150034382; the auto-increment serial number is 6, then the ID generation process is as follows:

[0045] Carry out high 64bit calculation: shift the APPID number on the host to 14678502 to the left by 32bit, divide the ip address into: 192, 132, 2, 65, and perform displacement filling respectively.

[0046]

[0047]

[0048] OR the APPID with the ip address:

[0049]

[0050] Assign the lower 64 bits: the first position is 0, the timestamp is shifted left by 22 bits,

[0051]

[0052]

[0053]

[0054] OR the timestamp with the auto-incrementing sequence number

[0055]

[0056] Splice the high 64bit and low 64bit together to generate a unique ID: 6304368927414739221705276340000006.

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

PUM

No PUM Login to View More

Abstract

The invention discloses a method for generating an unique ID in a distributed system, related to the field of distributed systems. The method for generating the unique ID in the distributed system is characterized by performing segmented assignment on the ID and storing the APPID of the host, the IP address of the host, the timestamp, and the time self-increasing sequence respectively. The generation speed is fast caused by the shift stitching of different data modules; and the required business information can be carried, therefore, the acquisition and distribution of the information can be easily performed among the distributed systems. According to the method for generating the unique ID in the distributed system, the communication with any external storage devices is not performed in the process of generating the ID, therefore, the possibility of errors is greatly reduced, and the generation process is accelerated; the generation of the ID is based on the timestamp, therefore, the generated ID is monotonic and ordered; and the APPID, IP, millisecond time and sequence number in milliseconds are stitched, therefore, the extension can be performed in the whole IP range, and the requirement of applying the distributed deployment more is greatly met.

Description

technical field [0001] The invention relates to the field of distributed systems, in particular to a method for generating a unique ID in a distributed system. Background technique [0002] In the distributed system, it is necessary to distinguish and identify the machines and equipment in the system. In order to identify different machines and equipment in these different systems, it is necessary to establish the identity serial number of each machine and equipment. This serial number is what we often say ID, in a system we need the ID of each machine device to be unique. [0003] Existing typical solutions include: 1. Database self-growth sequence or field; method: use database, unique in the entire database, advantages: simple, convenient, acceptable performance, natural sorting of IDs, disadvantages: single point risk, when the amount of data exceeds the database When accessing capabilities, you will encounter scaling and performance bottlenecks. 2. UUID, method: direc...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

Application Information

Patent Timeline
no application Login to View More
IPC IPC(8): H04L29/12
CPCH04L61/3015H04L2101/30H04L2101/33
Inventor 曾昌强周昊张伟
Owner 成都数联铭品科技有限公司
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Patsnap Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Patsnap Eureka Blog
Learn More
PatSnap group products