CN108282531A - A kind of uniqueness ID generation methods based on distributed system - Google Patents

A kind of uniqueness ID generation methods based on distributed system Download PDF

Info

Publication number
CN108282531A
CN108282531A CN201810068918.8A CN201810068918A CN108282531A CN 108282531 A CN108282531 A CN 108282531A CN 201810068918 A CN201810068918 A CN 201810068918A CN 108282531 A CN108282531 A CN 108282531A
Authority
CN
China
Prior art keywords
waiter
uniqueness
useful person
distributed system
contract
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
Application number
CN201810068918.8A
Other languages
Chinese (zh)
Inventor
余童
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Ou Chen Technology Co Ltd
Original Assignee
Shenzhen Ou Chen Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Shenzhen Ou Chen Technology Co Ltd filed Critical Shenzhen Ou Chen Technology Co Ltd
Priority to CN201810068918.8A priority Critical patent/CN108282531A/en
Publication of CN108282531A publication Critical patent/CN108282531A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/09Mapping addresses
    • H04L61/25Mapping addresses of the same type
    • H04L61/2503Translation of Internet protocol [IP] addresses
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/146Markers for unambiguous identification of a particular session, e.g. session cookie or URL-encoding

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Multi Processors (AREA)

Abstract

The uniqueness ID generation methods based on distributed system that the invention discloses a kind of, comprise the steps of:A, after project application startup does not complete first, synchronization timing task is opened, periodically redis is called to register, renewed treaty instanceId;B, then the ID waiter for registering a specific duration grows up to be a useful person to generate Service Instance, merger later enters in the synchronization timing task in step A, in the presence of ID waiter grows up to be a useful person example, it can renew a contract to service, if it is unsuccessful into a short wait stage to renew a contract, a new ID waiter can be regenerated later to grow up to be a useful person, avoid the interruption situation of business, in the absence of ID waiter grows up to be a useful person example, new ID Service Instance generators can be regenerated immediately, when the present invention is efficiently solved using distributed system, system architecture faces Global ID and generates it is possible that repeating ID, the objective problem for causing entire business that can not be normally carried out.

Description

A kind of uniqueness ID generation methods based on distributed system
Technical field
The present invention relates to a kind of ID generation methods, specifically a kind of uniqueness ID generation methods based on distributed system.
Background technology
Current unique ID to solve distributed system has following solution:
1. generating unique ID using UUID;
2. using database sequence (sequence, a kind of ID from increase strategy)
3. the snowflake algorithm using twitter generates Global ID;
4. generating globally unique ID using the objectId of MongoDB.
The above method has the following disadvantages:
UUID:It is unordered, it is long, it is difficult to establish index.
MongoDB ObjectId:It is long, non-pure digi-tal.
Database is from increasing sequence:It is centrally generated, there is performance bottleneck.
Snowflake algorithm:It is centrally generated, it is independent to dispose ID generators.
Invention content
The uniqueness ID generation methods based on distributed system that the purpose of the present invention is to provide a kind of, to solve the above-mentioned back of the body The problem of being proposed in scape technology.
To achieve the above object, the present invention provides the following technical solutions:
A kind of uniqueness ID generation methods based on distributed system, comprise the steps of:
A, after project application startup does not complete first, synchronization timing task is opened, periodically redis is called to register, is renewed a contract instanceId;
B, the ID waiter for registering a specific duration grows up to be a useful person to generate Service Instance, and merger later enters synchronizing in step A and determines When task in, in the presence of ID waiter grows up to be a useful person example, can renew a contract to service, if renew a contract it is unsuccessful enter it is one short Temporary loitering phase can regenerate a new ID waiter and grow up to be a useful person, the interruption situation of business be avoided, as ID waiter later It grows up to be a useful person in the absence of example, new ID Service Instance generators can be regenerated immediately.
As further scheme of the invention:The generation of ID Service Instance generators is IPV4 according to place gateway Location carries out the acquisition work of machine unique device id.
As further scheme of the invention:The specific generation strategy of ID:2 system numbers that ID is 64 can finally incite somebody to action It is converted into 14 10 system long numbers.
As further scheme of the invention:When generating 64 2 system numbers, the byte of highest order can be marked as not It can use, preceding 41 bit byte is the timestamp as unit of microsecond, and and then 10 bytes are what redis was generated according to IPV4 Machine ID, last 12 bytes are summary counters, and the counter is in system.
Compared with prior art, the beneficial effects of the invention are as follows:1, efficient, speed is fast;2, other technologies are combined Advantage, when efficiently solving using distributed system, system architecture faces Global ID and generates it is possible that repetition ID, causes whole The objective problem that a business can not be normally carried out.
Description of the drawings
The work flow diagram of Fig. 1 present invention.
Specific implementation mode
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete Site preparation describes, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.It is based on Embodiment in the present invention, it is obtained by those of ordinary skill in the art without making creative efforts every other Embodiment shall fall within the protection scope of the present invention.
Referring to Fig. 1, in the embodiment of the present invention, a kind of uniqueness ID generation methods based on distributed system, including with Lower step:
A, after project application startup does not complete first, synchronization timing task is opened, periodically redis is called to register, is renewed a contract instanceId;
B, and then the ID waiter of one specific duration of registration grows up to be a useful person to generate Service Instance.Merger later enters same in step 1 It walks in timed task, in the presence of ID waiter grows up to be a useful person example, can renew a contract to service, if renewed treaty is unsuccessful to enter one A short wait stage can regenerate a new ID waiter and grow up to be a useful person, avoid the interruption situation of business later.When ID takes It is engaged in the absence of generator example, new ID Service Instance generators can be regenerated immediately.
C, the generation of ID Service Instances generator is the addresses IPV4 according to place gateway, carries out machine unique device id Acquisition work;
D, the specific generation strategy of ID:2 system numbers that ID is 64, can finally be translated into 14 10 system long numbers
E, when generating 64 2 system numbers, the byte of highest order can be marked as unavailable, and it is single that preceding 41 bit byte, which is with microsecond, The timestamp of position, and then 10 bytes are the machine ID that redis is generated according to IPV4, and last 12 bytes are cumulative meters Number device, the counter is in software.
F, because computer storage number is all storage digital complement, the source code of positive number, complement code, radix-minus-one complement are all, negative Several complement codes is that its radix-minus-one complement adds one.Symbol is to pull constant when inverse operations, to participate in transporting when doing logical AND or non-, xor operation It calculates.
It is obvious to a person skilled in the art that invention is not limited to the details of the above exemplary embodiments, Er Qie In the case of without departing substantially from spirit or essential attributes of the invention, the present invention can be realized in other specific forms.Therefore, no matter From the point of view of which point, the present embodiments are to be considered as illustrative and not restrictive, and the scope of the present invention is by appended power Profit requires rather than above description limits, it is intended that all by what is fallen within the meaning and scope of the equivalent requirements of the claims Variation is included within the present invention.Any reference signs in the claims should not be construed as limiting the involved claims.
In addition, it should be understood that although this specification is described in terms of embodiments, but not each embodiment is only wrapped Containing an independent technical solution, this description of the specification is merely for the sake of clarity, and those skilled in the art should It considers the specification as a whole, the technical solutions in the various embodiments may also be suitably combined, forms those skilled in the art The other embodiment being appreciated that.

Claims (4)

1. a kind of uniqueness ID generation methods based on distributed system, which is characterized in that comprise the steps of:
After project application startup does not complete first, synchronization timing task is opened, periodically redis is called to register, is renewed a contract instanceId;
Then the ID waiter for registering a specific duration grows up to be a useful person to generate Service Instance, and merger later enters the synchronization in step A It in timed task, in the presence of ID waiter grows up to be a useful person example, can renew a contract to service, if it is unsuccessful into one to renew a contract The short wait stage can regenerate a new ID waiter and grow up to be a useful person, avoid the interruption situation of business later, when ID is serviced In the absence of generator example, new ID Service Instance generators can be regenerated immediately.
2. the uniqueness ID generation methods according to claim 1 based on distributed system, which is characterized in that ID services are real The generation of example generator is the addresses IPV4 according to place gateway, carries out the acquisition work of machine unique device id.
3. the uniqueness ID generation methods according to claim 1 based on distributed system, which is characterized in that ID's is specific Generation strategy:2 system numbers that ID is 64, can finally be translated into 14 10 system long numbers.
4. the uniqueness ID generation methods according to claim 1 based on distributed system, which is characterized in that generating 64 When 2 system number of position, the byte of highest order can be marked as unavailable, and preceding 41 bit byte is the timestamp as unit of microsecond, And then 10 bytes are the machine ID that redis is generated according to IPV4, and last 12 bytes are summary counters, which exists In system.
CN201810068918.8A 2018-01-24 2018-01-24 A kind of uniqueness ID generation methods based on distributed system Pending CN108282531A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810068918.8A CN108282531A (en) 2018-01-24 2018-01-24 A kind of uniqueness ID generation methods based on distributed system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810068918.8A CN108282531A (en) 2018-01-24 2018-01-24 A kind of uniqueness ID generation methods based on distributed system

Publications (1)

Publication Number Publication Date
CN108282531A true CN108282531A (en) 2018-07-13

Family

ID=62804912

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810068918.8A Pending CN108282531A (en) 2018-01-24 2018-01-24 A kind of uniqueness ID generation methods based on distributed system

Country Status (1)

Country Link
CN (1) CN108282531A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109325016A (en) * 2018-09-12 2019-02-12 杭州朗和科技有限公司 Data migration method, device, medium and electronic equipment
CN112054919A (en) * 2020-08-03 2020-12-08 华人运通(江苏)技术有限公司 Method, device, storage medium and system for generating ID (identity) of container cluster under stateless condition
CN112235431A (en) * 2020-09-30 2021-01-15 银盛支付服务股份有限公司 Method and system for automatically configuring machine ID based on snowflake algorithm
CN112966035A (en) * 2021-03-08 2021-06-15 深圳证券通信有限公司 Distributed digital ID generation algorithm
CN113032131A (en) * 2021-05-26 2021-06-25 天津中新智冠信息技术有限公司 Redis-based distributed timing scheduling system and method
CN114244807A (en) * 2022-02-25 2022-03-25 山东宁泓信息技术有限公司 Distributed ID generation system

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101796795A (en) * 2007-09-03 2010-08-04 英国电讯有限公司 Distributed system
CN102339303A (en) * 2010-07-20 2012-02-01 西门子公司 Distributed system
CN103838604A (en) * 2013-12-13 2014-06-04 广东天拓资讯科技有限公司 Method for generating distributed globally unique ID
CN106572165A (en) * 2016-10-26 2017-04-19 宜人恒业科技发展(北京)有限公司 Distributed global unique ID application method
CN106776932A (en) * 2016-12-01 2017-05-31 湖北荆楚网络科技股份有限公司 A kind of method that unique ID is generated in distributed system
CN107454203A (en) * 2017-07-19 2017-12-08 成都数联铭品科技有限公司 The method for generating unique ID in a distributed system

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101796795A (en) * 2007-09-03 2010-08-04 英国电讯有限公司 Distributed system
CN102339303A (en) * 2010-07-20 2012-02-01 西门子公司 Distributed system
CN103838604A (en) * 2013-12-13 2014-06-04 广东天拓资讯科技有限公司 Method for generating distributed globally unique ID
CN106572165A (en) * 2016-10-26 2017-04-19 宜人恒业科技发展(北京)有限公司 Distributed global unique ID application method
CN106776932A (en) * 2016-12-01 2017-05-31 湖北荆楚网络科技股份有限公司 A kind of method that unique ID is generated in distributed system
CN107454203A (en) * 2017-07-19 2017-12-08 成都数联铭品科技有限公司 The method for generating unique ID in a distributed system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
化简为繁: "分布式系统唯一性ID生成策略思考", 《简书》 *

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109325016A (en) * 2018-09-12 2019-02-12 杭州朗和科技有限公司 Data migration method, device, medium and electronic equipment
CN112054919A (en) * 2020-08-03 2020-12-08 华人运通(江苏)技术有限公司 Method, device, storage medium and system for generating ID (identity) of container cluster under stateless condition
CN112054919B (en) * 2020-08-03 2022-08-16 华人运通(江苏)技术有限公司 Method, device, storage medium and system for generating ID (identity) of container cluster under stateless condition
CN112235431A (en) * 2020-09-30 2021-01-15 银盛支付服务股份有限公司 Method and system for automatically configuring machine ID based on snowflake algorithm
CN112966035A (en) * 2021-03-08 2021-06-15 深圳证券通信有限公司 Distributed digital ID generation algorithm
CN113032131A (en) * 2021-05-26 2021-06-25 天津中新智冠信息技术有限公司 Redis-based distributed timing scheduling system and method
CN114244807A (en) * 2022-02-25 2022-03-25 山东宁泓信息技术有限公司 Distributed ID generation system

Similar Documents

Publication Publication Date Title
CN108282531A (en) A kind of uniqueness ID generation methods based on distributed system
US10678694B2 (en) System and method for creating time-accurate event streams
CN109542865A (en) Distributed cluster system configuration file synchronous method, device, system and medium
ES2812765T3 (en) Apparatus, system and method for processing application log data
CN102035738B (en) Method and device for acquiring routing information
CN111934890A (en) Key generation method, signature and signature verification method, device, equipment and medium
CN105450712A (en) Data transmission method and device
CN103117864B (en) The method of a kind of subnet merging and device
CN113489583A (en) Data processing method and device in multi-party privacy intersection and electronic equipment
CN102739502A (en) Method for realizing network identification conversion, apparatus and system thereof
CN111147181B (en) Service sending method, service receiving method, device, system and storage medium
CN104881485A (en) Data synchronizing method and system
CN104618414B (en) A kind of implementation method of Distributed Services, service broker's device and distributed system
WO2024207708A1 (en) Communication processing method and device for distributed data storage
CN103646015A (en) Method and system for sending, receiving and transmitting XML message
CN105447141A (en) Data processing method and node
CN110473088B (en) Block chain-based band type data processing method and system
CN104580456B (en) A kind of dynamic message distribution method and system for distributed system
CN103166847A (en) Method and device for ensuring graceful restart
CN109802872B (en) Message capturing method, device and equipment
US11106656B2 (en) Method and apparatus for a software-seamed and augmented view of an asynchronous network fabric
CN115695920A (en) Flume-based rtsp camera video stream access method
CN105376099A (en) Method and system for collecting virtual network flow in data switch
CN113434523B (en) Service data updating method, device, equipment and storage medium based on big data
CN105739947A (en) Register conflict detection method and apparatus

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

Application publication date: 20180713

RJ01 Rejection of invention patent application after publication