CN106776932A - A kind of method that unique ID is generated in distributed system - Google Patents
A kind of method that unique ID is generated in distributed system Download PDFInfo
- Publication number
- CN106776932A CN106776932A CN201611091996.7A CN201611091996A CN106776932A CN 106776932 A CN106776932 A CN 106776932A CN 201611091996 A CN201611091996 A CN 201611091996A CN 106776932 A CN106776932 A CN 106776932A
- Authority
- CN
- China
- Prior art keywords
- converted
- binary
- numerical value
- computing
- millisecond
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/21—Design, administration or maintenance of databases
Abstract
The present invention relates to a kind of method of ID generations, particularly a kind of method that unique ID is generated in distributed system, distinctive feature of the invention is:The long types integer of one 64 is decoupled by setting position, by sequence number in current time millisecond number, type of service, service module numbering, server numbering, millisecond, a long type integer is filled into by displacement.The advantage of the invention is that:With the method generation ID not only efficiency highs, performance impact and convenient with the system integration will not be caused to the inquiry of big data quantity and paging.
Description
Technical field
The present invention relates to a kind of method of ID generations, particularly a kind of method that unique ID is generated in distributed system.
Background technology
In a distributed system, how the unique ID of generation system rapidly and efficiently, be design a system when pass through
The problem being commonly encountered.The method of generation ID mainly has following three kinds in the prior art, to adapt to different scenes, demand and property
Can require, but all there is respective defect.
1. database self-propagation sequence
Realized using the self-propagation sequence of database, realized simply, ID is in order, helpful to paging and sequence.But it is different
Database, sequence syntax and realize it is different, database migration, multilist merge and during database point table point storehouse very
Trouble.And in the case of single database or read and write abruption or one master and multiple slaves, only one of which storehouse formation sequence has single-point
The risk of failure.
2.UUID
UUID codes are simple, and generation ID performances very well, will not there is performance issue substantially, and the UUID whole world is unique, in Data Migration,
Data merge with when databases comparison, can tackle calmly.But UUID characters are unordered, it is impossible to ensure that trend is passed
Increase, influence is produced on data paging performance.
3.Redis generates ID
Guaranteed data security using the single thread of Redis, realized by atomic operation INCR and INCRBY.Can pass through simultaneously
The cluster of Redis realizes the problem of handling capacity higher and Single Point of Faliure.ID is generated using Redis and is independent of data, it is convenient
Flexibly, and performance be better than database.It is helpful to paging and sequence and the ID of generation is ordered into, but it is necessarily dependent upon the
Tripartite instrument Redis, increased the complexity of the system integration.
The content of the invention
It is an object of the invention to provide a kind of method that unique ID is generated in distributed system, generated with the method
ID not only efficiency highs, will not cause performance impact and convenient with the system integration to the inquiry of big data quantity and paging.
Realizing the technical scheme of the object of the invention is:A kind of method that unique ID is generated in distributed system, its feature
It is:Comprise the following steps:
1.1. the acquiescence basal latency of server settings is obtained, the acquiescence basal latency is converted into binary system and displacement filling is done
Computing, is moved to left 24;
1.2. type of service numerical value is obtained, the type of service numerical value is converted into binary system and displacement filling computing is done, will converted
The binary numeral for getting moves to left 20;
1.3. COS numerical value is obtained, the COS numerical value is converted into binary system and displacement filling computing is done, will converted
The binary numeral for getting moves to left 16;
1.4. server number numerical value is obtained, the server number numerical value is converted into binary system and displacement filling computing is done, will converted
The binary numeral for getting moves to left 12;
1.5. obtain in millisecond from numerical value is increased, numerical value will be certainly increased in the millisecond and is converted into binary system;
1.6. 5 binary systems that step 1.1~1.5 computing is obtained are carried out or computing, the ID values of binary format is obtained, by this
The ID values of binary format are converted into the decimal system and obtain unique ID value.
The advantage of the invention is that:1. ID efficiency highs are generated, the business demand of high concurrent system is disclosure satisfy that.2. generate
ID is for numeral and increases in order, will not cause performance impact to the inquiry of big data quantity and paging.3. this method can be with system
Quick Seamless integration-, it is not necessary to the support of third party's tool storage room and third party software, reduces system integration difficulty.
Brief description of the drawings
Fig. 1 is the logic step flow chart of this method.
Specific embodiment
A kind of method of ID generations, particularly a kind of method that unique ID is generated in distributed system, it is characterised in that:
Comprise the following steps:
1.1. the acquiescence basal latency of server settings is obtained, the acquiescence basal latency is converted into binary system and displacement filling is done
Computing, is moved to left 24;
1.2. type of service numerical value is obtained, the type of service numerical value is converted into binary system and displacement filling computing is done, will converted
The binary numeral for getting moves to left 20;
1.3. COS numerical value is obtained, the COS numerical value is converted into binary system and displacement filling computing is done, will converted
The binary numeral for getting moves to left 16;
1.4. server number numerical value is obtained, the server number numerical value is converted into binary system and displacement filling computing is done, will converted
The binary numeral for getting moves to left 12;
1.5. obtain in millisecond from numerical value is increased, numerical value will be certainly increased in the millisecond and is converted into binary system;
1.6. 5 binary systems that step 1.1~1.5 computing is obtained are carried out or computing, the ID values of binary format is obtained, by this
The ID values of binary format are converted into the decimal system and obtain unique ID value.
Embodiment,
1)Obtain the millisecond number of current time:762824999253053440;
2)It is assumed that the basal latency millisecond number set in system is 1288834974657, therefore subtract basal latency millisecond number:
762824999253053440 - 1288834974657 = 762823710418078783;
3)Assuming that system business type, COS, subordinate server are respectively 2,9,1, current type of service, service are obtained
Type, server number numerical value;
4)Obtain in millisecond from increasing number 5;
5)Calculate id:
Step a:Millisecond number 762824999253053440 is subtracted 1288834974657, is obtained
762823710418078783, it is 2269171050489053184 to move to left 24 numerical value for obtaining;
Millisecond number | |
The decimal system | 762823710418078783 |
Binary system(64) | 0000101010010110000110000001111101111101101101110000110000111111 |
Operation | Move to left 24 |
Binary value(64) | 0001111101111101101101110000110000111111000000000000000000000000 |
It is converted into the decimal system | 2269171050489053184 |
Step b:It is 2097152 that type of service numerical value 2 is moved to left into 20 numerical value for obtaining;
Millisecond number | |
The decimal system | 2 |
Binary system(64) | 0000000000000000000000000000000000000000000000000000000000000010 |
Operation | Move to left 20 |
Binary value(64) | 0000000000000000000000000000000000000000001000000000000000000000 |
It is converted into the decimal system | 2097152 |
Step c:It is 589824 that COS numerical value 9 is moved to left into 16 numerical value for obtaining;
Millisecond number | |
The decimal system | 9 |
Binary system(64) | 0000000000000000000000000000000000000000000000000000000000001001 |
Operation | Move to left 16 |
Binary value(64) | 0000000000000000000000000000000000000000000010010000000000000000 |
It is converted into the decimal system | 589824 |
Step d:It is 4096 that server number numerical value 1 is moved to left into 12 numerical value for obtaining;
Millisecond number | |
The decimal system | 1 |
Binary system(64) | 0000000000000000000000000000000000000000000000000000000000000001 |
Operation | Move to left 12 |
Binary value(64) | 0000000000000000000000000000000000000000000000000001000000000000 |
It is converted into the decimal system | 4096 |
Step e:Do not operated from increasing numerical value 5 in millisecond;
Millisecond number | |
The decimal system | 5 |
Binary system(64) | 0000000000000000000000000000000000000000000000000000000000000101 |
Operation | Nothing |
Binary value(64) | 0000000000000000000000000000000000000000000000000000000000000101 |
It is converted into the decimal system | 5 |
step f:The numerical value that above-mentioned 5 step is obtained is carried out or budget obtains ID values
It is 2269171050491744261 by can obtain current ID values after above-mentioned steps.
Claims (1)
1. a kind of method that unique ID is generated in distributed system, it is characterised in that:Comprise the following steps:
1.1. the acquiescence basal latency of server settings is obtained, the acquiescence basal latency is converted into binary system and displacement filling is done
Computing, is moved to left 24;
1.2. type of service numerical value is obtained, the type of service numerical value is converted into binary system and displacement filling computing is done, will converted
The binary numeral for getting moves to left 20;
1.3. COS numerical value is obtained, the COS numerical value is converted into binary system and displacement filling computing is done, will converted
The binary numeral for getting moves to left 16;
1.4. server number numerical value is obtained, the server number numerical value is converted into binary system and displacement filling computing is done, will converted
The binary numeral for getting moves to left 12;
1.5. obtain in millisecond from numerical value is increased, numerical value will be certainly increased in the millisecond and is converted into binary system;
1.6. 5 binary systems that step 1.1~1.5 computing is obtained are carried out or computing, the ID values of binary format is obtained, by this
The ID values of binary format are converted into the decimal system and obtain unique ID value.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201611091996.7A CN106776932A (en) | 2016-12-01 | 2016-12-01 | A kind of method that unique ID is generated in distributed system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201611091996.7A CN106776932A (en) | 2016-12-01 | 2016-12-01 | A kind of method that unique ID is generated in distributed system |
Publications (1)
Publication Number | Publication Date |
---|---|
CN106776932A true CN106776932A (en) | 2017-05-31 |
Family
ID=58913705
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201611091996.7A Pending CN106776932A (en) | 2016-12-01 | 2016-12-01 | A kind of method that unique ID is generated in distributed system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106776932A (en) |
Cited By (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107247770A (en) * | 2017-06-05 | 2017-10-13 | 广东亿迅科技有限公司 | Global sequence's generation method and device based on zookeeper |
CN107454203A (en) * | 2017-07-19 | 2017-12-08 | 成都数联铭品科技有限公司 | The method for generating unique ID in a distributed system |
CN108282531A (en) * | 2018-01-24 | 2018-07-13 | 深圳市欧辰技术有限公司 | A kind of uniqueness ID generation methods based on distributed system |
CN108322222A (en) * | 2018-01-16 | 2018-07-24 | 四川斐讯信息技术有限公司 | A method of it generates and using distributed unique ID |
CN108512914A (en) * | 2018-03-20 | 2018-09-07 | 北京奇艺世纪科技有限公司 | A kind of traffic ID generation method and device |
CN108647193A (en) * | 2018-04-20 | 2018-10-12 | 河南中烟工业有限责任公司 | A kind of unique identifier generation method can be applied to distributed system and device |
CN109165256A (en) * | 2017-06-28 | 2019-01-08 | 阿里巴巴集团控股有限公司 | A kind of method and system at configuration data center |
CN109636551A (en) * | 2019-01-31 | 2019-04-16 | 上海易点时空网络有限公司 | Service order generation method and device |
CN110505306A (en) * | 2019-08-30 | 2019-11-26 | 公安部交通管理科学研究所 | A kind of data ID generation method may specify digit |
CN110874308A (en) * | 2018-08-31 | 2020-03-10 | 北京京东尚科信息技术有限公司 | Method and device for generating unique value |
CN111901453A (en) * | 2020-07-25 | 2020-11-06 | 广州海鹚网络科技有限公司 | Identification generation method and device, computer equipment and storage medium |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101533414A (en) * | 2009-04-15 | 2009-09-16 | 阿里巴巴集团控股有限公司 | A method and a device for generating unique identifier of database record |
CN102769667A (en) * | 2012-06-29 | 2012-11-07 | 北京奇虎科技有限公司 | Method, equipment and system for generating ID |
CN103823810A (en) * | 2012-11-19 | 2014-05-28 | 中国电信股份有限公司 | Method, device and system for generating unique keys in distributed system |
CN104573088A (en) * | 2015-01-29 | 2015-04-29 | 北京京东尚科信息技术有限公司 | Document serial number generation method and device |
-
2016
- 2016-12-01 CN CN201611091996.7A patent/CN106776932A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101533414A (en) * | 2009-04-15 | 2009-09-16 | 阿里巴巴集团控股有限公司 | A method and a device for generating unique identifier of database record |
CN102769667A (en) * | 2012-06-29 | 2012-11-07 | 北京奇虎科技有限公司 | Method, equipment and system for generating ID |
CN103823810A (en) * | 2012-11-19 | 2014-05-28 | 中国电信股份有限公司 | Method, device and system for generating unique keys in distributed system |
CN104573088A (en) * | 2015-01-29 | 2015-04-29 | 北京京东尚科信息技术有限公司 | Document serial number generation method and device |
Cited By (17)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107247770A (en) * | 2017-06-05 | 2017-10-13 | 广东亿迅科技有限公司 | Global sequence's generation method and device based on zookeeper |
CN109165256A (en) * | 2017-06-28 | 2019-01-08 | 阿里巴巴集团控股有限公司 | A kind of method and system at configuration data center |
CN107454203A (en) * | 2017-07-19 | 2017-12-08 | 成都数联铭品科技有限公司 | The method for generating unique ID in a distributed system |
CN108322222A (en) * | 2018-01-16 | 2018-07-24 | 四川斐讯信息技术有限公司 | A method of it generates and using distributed unique ID |
CN108282531A (en) * | 2018-01-24 | 2018-07-13 | 深圳市欧辰技术有限公司 | A kind of uniqueness ID generation methods based on distributed system |
CN108512914B (en) * | 2018-03-20 | 2021-07-23 | 北京奇艺世纪科技有限公司 | Service ID generation method and device |
CN108512914A (en) * | 2018-03-20 | 2018-09-07 | 北京奇艺世纪科技有限公司 | A kind of traffic ID generation method and device |
CN108647193B (en) * | 2018-04-20 | 2021-11-19 | 河南中烟工业有限责任公司 | Unique identifier generation method and device applicable to distributed system |
CN108647193A (en) * | 2018-04-20 | 2018-10-12 | 河南中烟工业有限责任公司 | A kind of unique identifier generation method can be applied to distributed system and device |
CN110874308A (en) * | 2018-08-31 | 2020-03-10 | 北京京东尚科信息技术有限公司 | Method and device for generating unique value |
CN110874308B (en) * | 2018-08-31 | 2024-02-06 | 北京京东尚科信息技术有限公司 | Method and device for generating unique value |
CN109636551A (en) * | 2019-01-31 | 2019-04-16 | 上海易点时空网络有限公司 | Service order generation method and device |
CN109636551B (en) * | 2019-01-31 | 2022-02-01 | 上海易点时空网络有限公司 | Service order generation method and device |
CN110505306A (en) * | 2019-08-30 | 2019-11-26 | 公安部交通管理科学研究所 | A kind of data ID generation method may specify digit |
CN110505306B (en) * | 2019-08-30 | 2021-12-21 | 公安部交通管理科学研究所 | Data ID generation method capable of specifying digit |
CN111901453A (en) * | 2020-07-25 | 2020-11-06 | 广州海鹚网络科技有限公司 | Identification generation method and device, computer equipment and storage medium |
CN111901453B (en) * | 2020-07-25 | 2023-07-07 | 广州海鹚网络科技有限公司 | Identification generation method, device, computer equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106776932A (en) | A kind of method that unique ID is generated in distributed system | |
US10048864B2 (en) | Dynamically configuring erasure code redundancy and distribution | |
US20190042611A1 (en) | Technologies for structured database query for finding unique element values | |
JP2020509495A (en) | Method and apparatus for writing service data to block chain and method for determining service subset | |
US9002907B2 (en) | Method and system for storing binary large objects (BLObs) in a distributed key-value storage system | |
US9619492B2 (en) | Data migration | |
CN107085570B (en) | Data processing method, application server and router | |
CN106599104A (en) | Mass data association method based on redis cluster | |
US10509582B2 (en) | System and method for data storage, transfer, synchronization, and security | |
KR102111871B1 (en) | Method and apparatus for generating random string | |
CN104216961A (en) | Method and device for data processing | |
US20200356293A1 (en) | Variable Length Deduplication of Stored Data | |
CN104615713A (en) | SQL executing method and device based on multiple database types | |
CN102215264B (en) | Method and device for supporting multi-tenancy data and service customized running | |
CN107066205B (en) | Data storage system | |
CN110019169B (en) | Data processing method and device | |
WO2014180411A1 (en) | Distributed index generation method and device | |
WO2016206377A1 (en) | Data integration and processing method and device | |
CN105550309A (en) | MPP framework database cluster sequence system and sequence management method | |
CN104008191A (en) | Data inquiring method | |
CN105447183A (en) | MPP framework database cluster sequence system and sequence management method | |
CN107665241B (en) | Real-time data multi-dimensional duplicate removal method and device | |
CN112131229A (en) | Block chain-based distributed data access method and device and storage node | |
US11386110B2 (en) | Data sorting system and implementation method thereof | |
CN106021427B (en) | Dynamic interaction method, device and system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20170531 |