CN109241056A - A kind of digital ID generation system for distributed system - Google Patents
A kind of digital ID generation system for distributed system Download PDFInfo
- Publication number
- CN109241056A CN109241056A CN201810969665.1A CN201810969665A CN109241056A CN 109241056 A CN109241056 A CN 109241056A CN 201810969665 A CN201810969665 A CN 201810969665A CN 109241056 A CN109241056 A CN 109241056A
- Authority
- CN
- China
- Prior art keywords
- data
- tables
- module
- field
- database
- 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.)
- Granted
Links
Abstract
The present invention relates to distributed system configuration management technical field, specially a kind of digital ID for distributed system generates system, and database, database is interior to be equipped with N ID tables of data, and creation has an id field in every ID tables of data;Id field is from increasing type, and from increasing, step-length is N and the initial value of the id field of N ID tables of data successively adds one;Application module, application module includes tables of data routing module and ID generation module, tables of data routing module is used to randomly select an ID tables of data after the call request that application receives ID generation, ID generation module, which is used to send data to the ID tables of data of selection, generates order, and ID tables of data returns to the id field value for generating data.A kind of digital ID for distributed system provided by the invention generates system, and it is low and the problems such as can not cope with more complications not can guarantee increasing trend, search efficiency present in the generation system for being able to solve existing number ID.
Description
Technical field
The present invention relates to distributed system configuration management technical field, specially a kind of digital ID for distributed system
Generation system.
Background technique
In a distributed system, it is often necessary to define corresponding data using globally unique number ID.This number ID base
This demand includes the following: 1, globally unique;2, occupancy is relatively fewer, facilitates ID carrying out DB storage, facilitate index;3, when
Between it is friendly, facilitate service inquiry;4, performance is high, and availability is high.
Realize that the mode of unique number ID is more, common are following several under distributed system:
1, UUID algorithm, core concept are that the hardware in conjunction with machine, time and random seed number are unique to generate
Digital ID.
2, the distributed ID generator based on Redis: using 41bit come the resting period, it is accurate to millisecond, can be used 41
Year;Logic fragment ID is stored using 12bit, maximum fragment ID is 4095;Self-propagation ID is stored using 10bit, it is meant that
Each node, every millisecond at most can be generated 1024 ID.
3, queue/pond ID mode pre-generates a certain amount of number ID, and is put into a queue/pond ID, every time
When operation, an ID is read from queue.
In the above mode, the shortcomings that UUID, is that it not can guarantee trend and is incremented by, if while UUID it is too long, often
With string representation, establish search index low efficiency as major key, common prioritization scheme be " storing by half " however by half after simultaneously
It cannot be guaranteed uniqueness.The shortcomings that distributed ID generator based on Redis be to need individually to dispose Redis and performance compared with
Difference, deficient in stability.And the shortcomings that pond ID, is, needs to generate in advance, not can guarantee trend is incremented by, and needs to dispose individual clothes
Business is safeguarded.In the case where Distributed Application service extending transversely, above several ways cannot all accomplish it is not only stable but also high
Effect ground generates the unique ID of numeric type.
Summary of the invention
The invention is intended to provide a kind of digital ID generation system for distributed system, it is able to solve existing number ID
Generation system present in not can guarantee increasing trend, search efficiency low and the problems such as can not cope with more complications.
In order to solve the above-mentioned technical problem, this patent provides the following technical solutions:
A kind of digital ID generation system for distributed system, comprising:
Database, the database is interior to be equipped with N ID tables of data, and creation has an ID in ID tables of data described in every
Field;Id field is from increasing type, and from increasing, step-length is N and the initial value of the id field of N ID tables of data successively adds one;
Application module, the application module include tables of data routing module and ID generation module, and the tables of data routes mould
Block is used to after the call request that application receives ID generation randomly select ID tables of data, and the ID generation module is used for selection
ID tables of data send data generate order, ID tables of data return generate data id field value, ID generation module is according to ID word
Segment value generates number ID and returns to caller.
In technical solution of the present invention, multiple ID tables of data are created in the database, utilize the field of tables of data in database
From function is increased, guarantee number ID from increasing, by the way that the initial value and step-length of each ID tables of data is arranged, guarantee its from after increasing not
It can repeat, it is ensured that the uniqueness of digital ID;It, can be the high concurrent the case where by using the mode that more tables of data route
Under, the read-write amount of forms data table is reduced, the pressure of high concurrent is coped with, it is ensured that digital ID's efficiently produces, and guarantees that system stablizes work
Make.Simultaneously because ID generation is carried out by the way of database, when performance requirement is higher, it is only necessary to increase database server
Number, this is advantage not available for present UUID mode and Redis mode;Due to itself being exactly to utilize number
Therefore ID is easily carried out DB storage or index by the ID generated according to library.
Further, the database is multiple databases, and tables of data routing module includes that database chooses module and data
Table chooses module, and database chooses module and chooses mould for randomly choosing P database, the tables of data in existing database
Block from the database of selection for randomly selecting Q ID tables of data.
The pressure of single database can be effectively reduced in multiple database, is conducive to the balanced allotment loaded, and reply is high
Concurrent problem.
Further, the P and Q is 1.
Further, the application is multiple applications, further includes using routing module, the application routing module is used for basis
Call request is distributed to different application modules by the content and routing rule of call request.
If performance receives the limitation of database performance in operation, the number of database extending transversely can be passed through
(access multi-data source) improves performance.It, can be by increasing application clothes if performance receives the limitation of application server
The thinking of business application server number extending transversely, the expansion mode of technical scheme is extremely flexible, can be according to reality
Demand customizes the performance of service, is suitable for various enterprises.
Further, the type of the id field is bigint type.The data area of bigint type is that -2^63 arrives 2^
63-1, enough enterprises carry out using.
It further, further include that tables of data expands module, the tables of data expands module and includes:
Tables of data creation module, the tables of data creation module are used to open each field of ID tables of data according to original N
M newly-increased ID tables of data of creation in the database are set;
Maximum value screening module, the maximum value X of the id field for counting current original N ID tables of data;
Initial value setup module is followed successively by X+1 to X+N+M for the initial value of id field of N+M ID tables of data to be arranged;
Step-length setup module is N+M for the step-length that increases certainly of id field of N+M ID tables of data to be arranged.
When ID tables of data is expanded, by the way that initial value to be arranged on current maximum value, repetition is avoided the occurrence of
Digital ID.
It further, further include authority management module, the authority management module can be read and write for each application module
ID tables of data range.The read-write to tables of data of different applications is controlled by permission, and then control each application to make
ID range.
Further, ID tables of data further includes memo field, and the memo field is used to record the application message for generating the ID.
Traditional ID generation method can also store some relevant data of ID into database after generating ID, straight in this programme
It connects when generating, stores application message, facilitate and debugged and counted.
Detailed description of the invention
Fig. 1 is the flow diagram in a kind of digital ID generation system embodiment for distributed system of the present invention.
Specific embodiment
It is further described below by specific embodiment:
Embodiment one
As shown in Figure 1, a kind of digital ID for distributed system generates system in the present embodiment, including database, answer
With module and apply distribution module: wherein:
Database is multiple databases, is distributed on different database servers, and N ID data are equipped in database
Table, creation has an id field and a memo field in every ID tables of data;Id field is to increase type certainly, id field
Type is bigint type, and from increasing, step-length is N and the initial value of the id field of N ID tables of data successively adds one.
It is used to be distributed to call request according to the content and routing rule of call request using routing module different
Application module.
Application module includes tables of data routing module and ID generation module, and tables of data routing module is used to receive in application
An ID tables of data is randomly selected after the call request that ID is generated, tables of data routing module includes that database chooses module and data
Table chooses module, and database chooses module and chooses module for randomly choosing a database, tables of data in existing database
For randomly selecting an ID tables of data from the database of selection, ID generation module is used to send number to the ID tables of data of selection
It is ordered according to generating, ID tables of data returns to the id field value for generating data, and ID generation module is using the id field value as the ID generated
Return to caller.
It further include that tables of data expands module, authority management module, it includes tables of data creation module, most that tables of data, which expands module,
Big value screening module, initial value setup module and step-length setup module, tables of data creation module are used for according to original N ID numbers
M newly-increased ID tables of data are created in the database according to the setting of each field of table;Maximum value screening module is worked as counting
The maximum value X of the id field of preceding original N ID tables of data;Initial value setup module is used to be arranged the ID of N+M ID tables of data
The initial value of field is followed successively by X+1 to X+N+M;Step-length setup module is used to be arranged increasing certainly for the id field of N+M ID tables of data
Step-length is N+M.
When ID tables of data is expanded, by the way that initial value to be arranged on current maximum value, repetition is avoided the occurrence of
Digital ID.
Authority management module is used for the ID tables of data range that each application module can be read and write.It is controlled by permission different
Application the read-write to tables of data, and then control the ID range that each application is able to use.
In order to sufficiently disclose the course of work of the present embodiment, a kind of number based on above system is also disclosed in the present embodiment
Word ID generation method, this method includes the following contents:
Tables of data foundation step creates ID tables of data in the database;
Tables of data foundation step includes:
Step 1: N ID tables of data are created in the database;The database can may be most evidences for single database
Library is 3 databases in the present embodiment;
Step 2: an id field and a memo field are created in every ID tables of data;
Step 3: setting id field is to increase type certainly, while the type of data is bigint type, while being arranged from increasing step
The initial value of the id field of a length of N and N ID tables of data successively adds one.
Using routing step, call request is distributed to by different answer according to the content of call request and routing rule
With.
Tables of data routing step, using receive ID generation call request after randomly select an ID tables of data;Data
Table routing step includes database selecting step and tables of data selecting step, and database selecting step is in existing database
A database is randomly choosed, tables of data selecting step from the database of selection for randomly selecting an ID tables of data, originally
In embodiment, the permission of ID tables of data can be also set, permission can read and write the ID data for controlling in tables of data foundation step
The application of table obtains the ID tables of data in oneself extent of competence, then from these ID data first when using selection ID tables of data
An ID tables of data is randomly extracted in table.
ID generation step, using to the ID tables of data of selection execute generate order, ID tables of data generate a data and
The information of application is filled in memo field;The id field value that the data of generation are returned after what is said or talked about, using using the id field value as life
At ID return to using distributing programs, by returning to initial caller using distributing programs.
Further include that tables of data expands step, tables of data is expanded step and specifically included:
Step 1: M newly-increased ID numbers are created in the database according to the setting of each field of original N ID tables of data
According to table;
Step 2: the maximum value X of current original N ID tables of data is counted;
Step 3: the initial value of the id field of N+M ID tables of data of setting is followed successively by X+1 to X+N+M and is arranged from increasing step
A length of N+M.
Specific in the present embodiment, there are three applications altogether: App1, App2 and App3 and three databases DB1, DB2
And DB3, App1, App2, App3 can be understood as ISP, each ISP accesses multiple databases, often
3 tables for being specifically generated ID are created in a database, equipped with one from the id field increased, table tb1, tb2, tb3 ... tb9's is risen
Initial value is 1,2,3 respectively ... 9;And the step-length increased certainly is 9, guarantees number ID from increasing and uniqueness;It is first when calling every time
Distribution processor is first done by routing application, finds ISP, such as hit is App1, logarithm when App1 provides service
Route processing is done according to table, randomly selects an ID tables of data, such as DB3.tb8.Due to routing be it is random, long-play it
In tb1 afterwards, tb2 ... tb9 data volume will not difference it is too big, maximum value is relatively.
By using the mode that more tables of data route, the read-write amount of forms data table can be reduced in the case of high concurrency,
Cope with the pressure of high concurrent, it is ensured that digital ID's efficiently produces, and guarantees system steady operation.Simultaneously because using the side of database
Formula carries out ID generation, when performance requirement is higher, it is only necessary to increase the number of database server, this is present UUID
Advantage not available for mode and Redis mode.
The pressure of single database can be effectively reduced in multiple database, is conducive to the balanced allotment loaded, and reply is high
Concurrent problem.If performance receives the limitation of database performance in operation, of database extending transversely can be passed through
(access multi-data source) is counted to improve performance.If performance receives the limitation of application server, can be applied by increasing
The thinking of service application server number extending transversely, the expansion mode of technical scheme and its flexibly, can be according to reality
Border demand customizes the performance of service, is suitable for various enterprises.
Embodiment two
The difference between this embodiment and the first embodiment lies in the present embodiment, using according to the content of call request generate P and
The numerical value of Q, the call request include secrecy call request and common call request, and the secrecy call request includes secrecy etc.
Grade, the secrecy call request and common call request include equipment batch, and the security classification is higher, and P is bigger, described
Equipment batch is newer, and Q is bigger, and database chooses module and is used to randomly choose P database, the number in existing database
Module is chosen for randomly selecting Q ID tables of data from P database according to table, and ID generation module will be from Q ID tables of data
Obtained Q id field value splicing returns to caller as the ID generated, and P is bigger, and the database of selection is more, in turn
Q obtained ID tables of data is more random, and the randomness of the ID of generation is stronger, meets privacy requirements, and Q is bigger, the id field of selection
Value is more, and spliced field length is longer, in the present embodiment, by above-mentioned setting, can satisfy the demand of confidentiality, together
When Machine Batch newer P it is bigger, and then pass through the length of last ID value, so that it may learn in distributed system some ID pairs
The new and old and batch number for the machine answered, is conveniently scheduled, in same batch each machine due to ID tables of data itself be from
Increase, there is no repetitions, because the P value of the machine of different batches is different, final ID number can differ biggish quantity
Grade, such as when the ID value of increasing certainly of ID tables of data is three digit, P adds one every time, can mean that the order of magnitude increases 1000 times, therefore
The Serial Number Range of the machine of different batches is not overlapped substantially, in order to ensure digital ID is unique, can carry out weight after ID generation
Multiple verification step, in lookup system whether included number ID.
The above are merely the embodiment of the present invention, the common sense such as well known specific structure and characteristic are not made excessively herein in scheme
Description, all common of technical field that the present invention belongs to before one skilled in the art know the applying date or priority date
Technological know-how can know the prior art all in the field, and have using routine experiment means before the date
Ability, one skilled in the art can improve in conjunction with self-ability under the enlightenment that the application provides and implement we
Case, some typical known features or known method should not become the barrier that one skilled in the art implement the application
Hinder.It should be pointed out that for those skilled in the art, without departing from the structure of the invention, if can also make
Dry modification and improvement, these also should be considered as protection scope of the present invention, these all will not influence the effect that the present invention is implemented and
Patent practicability.The scope of protection required by this application should be based on the content of the claims, the specific reality in specification
Applying the records such as mode can be used for explaining the content of claim.
Claims (8)
1. a kind of digital ID for distributed system generates system, it is characterised in that: include:
Database, the database is interior to be equipped with N ID tables of data, and creation has an ID word in ID tables of data described in every
Section;Id field is from increasing type, and from increasing, step-length is N and the initial value of the id field of N ID tables of data successively adds one;
Application module, the application module include tables of data routing module and ID generation module, and the tables of data routing module is used
In randomly selecting ID tables of data after the call request that application receives ID generation, the ID generation module is used for the ID to selection
Tables of data sends data and generates order, and ID tables of data returns to the id field value for generating data, and ID generation module is according to id field value
It generates number ID and returns to caller.
2. a kind of digital ID for distributed system according to claim 1 generates system, it is characterised in that: the number
It is multiple databases according to library, tables of data routing module includes that database chooses module and tables of data selection module, and database is chosen
Module chooses module for the database from selection for randomly choosing P database, the tables of data in existing database
In randomly select Q ID tables of data.
3. a kind of digital ID for distributed system according to claim 2 generates system, it is characterised in that: the P
It is 1 with Q.
4. a kind of digital ID for distributed system according to claim 1 generates system, it is characterised in that: described to answer
With for multiple applications, further include using routing module, it is described using routing module for according to call request content and road
Call request is distributed to different application modules by rule.
5. a kind of digital ID for distributed system according to claim 1 generates system, it is characterised in that: the ID
The type of field is bigint type.
6. a kind of digital ID for distributed system according to claim 1 generates system, it is characterised in that: further include
Tables of data expands module, and the tables of data expands module and includes:
Tables of data creation module, the tables of data creation module are used for the setting of each field according to original N ID tables of data
M newly-increased ID tables of data of creation in the database;
Maximum value screening module, the maximum value X of the id field for counting current original N ID tables of data;
Initial value setup module is followed successively by X+1 to X+N+M for the initial value of id field of N+M ID tables of data to be arranged;
Step-length setup module is N+M for the step-length that increases certainly of id field of N+M ID tables of data to be arranged.
7. a kind of digital ID for distributed system according to claim 1 generates system, it is characterised in that: further include
Authority management module, the authority management module are used for the ID tables of data range that each application module can be read and write.
8. a kind of digital ID for distributed system according to claim 1 generates system, it is characterised in that: ID data
Table further includes memo field, and the memo field is used to record the application message for generating the ID.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810969665.1A CN109241056B (en) | 2018-08-23 | 2018-08-23 | Digital ID generation system for distributed system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810969665.1A CN109241056B (en) | 2018-08-23 | 2018-08-23 | Digital ID generation system for distributed system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109241056A true CN109241056A (en) | 2019-01-18 |
CN109241056B CN109241056B (en) | 2021-03-05 |
Family
ID=65067896
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810969665.1A Active CN109241056B (en) | 2018-08-23 | 2018-08-23 | Digital ID generation system for distributed system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109241056B (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110162293A (en) * | 2019-05-10 | 2019-08-23 | 上海紫翊网络科技有限公司 | A kind of random number generation method, device and terminal for equally loaded |
CN111680103A (en) * | 2020-05-29 | 2020-09-18 | 成都新希望金融信息有限公司 | Method and device for generating ordered unique value by distributed database self-increment field |
CN112380208A (en) * | 2020-10-21 | 2021-02-19 | 珠海许继芝电网自动化有限公司 | Method, system and medium for generating real-time data ID of distribution automation system |
CN115002078A (en) * | 2022-05-11 | 2022-09-02 | 北京奇艺世纪科技有限公司 | ID generation method and device |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20110314027A1 (en) * | 2008-11-03 | 2011-12-22 | China Mobile Communications Corporation | Index building, querying method, device, and system for distributed columnar database |
US20140201192A1 (en) * | 2013-01-15 | 2014-07-17 | Syscom Computer Engineering Co. | Automatic data index establishment method |
CN107360224A (en) * | 2017-07-07 | 2017-11-17 | 携程旅游信息技术(上海)有限公司 | Sequence number generation method, system, equipment and storage medium in distributed system |
CN107864233A (en) * | 2017-11-08 | 2018-03-30 | 千寻位置网络有限公司 | Globally unique ID structures and generation method |
CN108241715A (en) * | 2016-12-27 | 2018-07-03 | 苏宁云商集团股份有限公司 | A kind of distributed data base major key generation method and device |
CN108322222A (en) * | 2018-01-16 | 2018-07-24 | 四川斐讯信息技术有限公司 | A method of it generates and using distributed unique ID |
-
2018
- 2018-08-23 CN CN201810969665.1A patent/CN109241056B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20110314027A1 (en) * | 2008-11-03 | 2011-12-22 | China Mobile Communications Corporation | Index building, querying method, device, and system for distributed columnar database |
US20140201192A1 (en) * | 2013-01-15 | 2014-07-17 | Syscom Computer Engineering Co. | Automatic data index establishment method |
CN108241715A (en) * | 2016-12-27 | 2018-07-03 | 苏宁云商集团股份有限公司 | A kind of distributed data base major key generation method and device |
CN107360224A (en) * | 2017-07-07 | 2017-11-17 | 携程旅游信息技术(上海)有限公司 | Sequence number generation method, system, equipment and storage medium in distributed system |
CN107864233A (en) * | 2017-11-08 | 2018-03-30 | 千寻位置网络有限公司 | Globally unique ID structures and generation method |
CN108322222A (en) * | 2018-01-16 | 2018-07-24 | 四川斐讯信息技术有限公司 | A method of it generates and using distributed unique ID |
Non-Patent Citations (1)
Title |
---|
长河: "常见分布式全局唯一ID生成策略及算法的对比", 《HTTPS://BLOG.CSDN.NET/U010398771/ARTICLE/DETAILS/79765836》 * |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110162293A (en) * | 2019-05-10 | 2019-08-23 | 上海紫翊网络科技有限公司 | A kind of random number generation method, device and terminal for equally loaded |
CN111680103A (en) * | 2020-05-29 | 2020-09-18 | 成都新希望金融信息有限公司 | Method and device for generating ordered unique value by distributed database self-increment field |
CN112380208A (en) * | 2020-10-21 | 2021-02-19 | 珠海许继芝电网自动化有限公司 | Method, system and medium for generating real-time data ID of distribution automation system |
CN115002078A (en) * | 2022-05-11 | 2022-09-02 | 北京奇艺世纪科技有限公司 | ID generation method and device |
CN115002078B (en) * | 2022-05-11 | 2024-04-09 | 北京奇艺世纪科技有限公司 | ID generation method and device |
Also Published As
Publication number | Publication date |
---|---|
CN109241056B (en) | 2021-03-05 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109241056A (en) | A kind of digital ID generation system for distributed system | |
Demertzis et al. | Dynamic searchable encryption with small client storage | |
US8533489B2 (en) | Searchable symmetric encryption with dynamic updating | |
WO2021068726A1 (en) | Method and device for storing and searching for transaction hash value in blockchain | |
TWI737152B (en) | Block chain-based hierarchical storage method and device, and electronic equipment | |
Moataz et al. | Constant communication ORAM with small blocksize | |
EP1688860B1 (en) | Method for obfuscating data structures by deterministic natural data substitution | |
CN101587479B (en) | Database management system kernel oriented data encryption/decryption system and method thereof | |
CN106991334A (en) | A kind of method, system and device of data access | |
CN104135437B (en) | The apparatus and method searched for for the table that centralised storage device pond is utilized in the network switch | |
CN107147501A (en) | Timestamp processing method and processing device | |
KR20190122843A (en) | Blockchain ledger | |
CN109241057A (en) | A kind of digital ID generation method for distributed system | |
US11270227B2 (en) | Method for managing a machine learning model | |
WO2021057482A1 (en) | Method and device for generating bloom filter in blockchain | |
US7954158B2 (en) | Characterizing computer attackers | |
EP2778953A1 (en) | Encoded-search database device, method for adding and deleting data for encoded search, and addition/deletion program | |
CN105279198B (en) | Tables of data storage, modification, inquiry and statistical method | |
CN109785024A (en) | Invoice data processing method, device, computer equipment and storage medium | |
CN106844288A (en) | A kind of random string generation method and device | |
CN109802832A (en) | A kind of processing method of data file, system, big data processing server and computer storage medium | |
CN109358874A (en) | Business rule update method, device, computer equipment and storage medium | |
CN108399175B (en) | Data storage and query method and device | |
KR101428649B1 (en) | Encryption system for mass private information based on map reduce and operating method for the same | |
CN105224541B (en) | Uniqueness control method, information storage means and the device of data |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |