CN108206744A - The method and system of the high performance Serial No. generation of High Availabitity - Google Patents

The method and system of the high performance Serial No. generation of High Availabitity Download PDF

Info

Publication number
CN108206744A
CN108206744A CN201611165776.4A CN201611165776A CN108206744A CN 108206744 A CN108206744 A CN 108206744A CN 201611165776 A CN201611165776 A CN 201611165776A CN 108206744 A CN108206744 A CN 108206744A
Authority
CN
China
Prior art keywords
serial
bottom sequence
sequence
generation
client
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
Application number
CN201611165776.4A
Other languages
Chinese (zh)
Other versions
CN108206744B (en
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.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information 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 Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201611165776.4A priority Critical patent/CN108206744B/en
Publication of CN108206744A publication Critical patent/CN108206744A/en
Application granted granted Critical
Publication of CN108206744B publication Critical patent/CN108206744B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/08Configuration management of networks or network elements
    • H04L41/0803Configuration setting
    • H04L41/0823Configuration setting characterised by the purposes of a change of settings, e.g. optimising configuration for enhancing reliability
    • H04L41/0826Configuration setting characterised by the purposes of a change of settings, e.g. optimising configuration for enhancing reliability for reduction of network costs

Abstract

The present invention provides a kind of method and system of the high performance Serial No. generation of High Availabitity, can not need to server-side, and final Serial No. is made to generate logic and is all placed on client;And it can ensure the High Availabitity and high-performance of Serial No. generation.This method includes:Step 1:Client is asked according to Serial No., and Serial No. is obtained from memory queue, if there are Serial No.s in memory queue, directly returns to the Serial No., if there is no Serial No.s in memory queue, continues to execute step 2;Step 2:The client call bottom sequence generator generates bottom sequence;Step 3:The client generates several Serial No.s based on the bottom sequence;Step 4:The Serial No. to rank the first is returned, and remaining Serial No. is stored in memory queue, Serial No. is obtained in time to be directed to following digital sequence of requests.

Description

The method and system of the high performance Serial No. generation of High Availabitity
Technical field
The present invention relates to computer technology and software field more particularly to a kind of high performance Serial No. generations of High Availabitity Method and system.
Background technology
With the continuous development of computer technology, generation one is frequently necessary in each business scenario and ensures unique digital sequence Row, such as the express delivery odd numbers of e-commerce field, goods orders number or a point library are divided after table to ensure unique tables of data number Word major key etc..Each operation system meeting this kind of Serial No. generation method of heavy dependence, if Serial No. formation efficiency is low, meeting The efficiency of operation system is directly affected, if the generation of ordered series of numbers sequence is abnormal, it is unavailable operation system to be directly resulted in.
In the prior art the generation method of Serial No. approximately as:
1. Serial No. client request server-side obtains Serial No.;
2. Serial No. server-side has the generation that multiple servers support Serial No., is receiving to ensure High Availabitity It can be to database or can generate other middlewares of Serial No. sends out request after to Serial No. generation request;
The modes such as 1 is added to return to Serial No. to Serial No. 3. database or other middlewares are used from increasing ID or train value Server-side.Specific logical architecture can be found in Fig. 1.
But there are certain the defects of property for the prior art:
1) it during Serial No. client request generation Serial No., needs first to ask server-side, server-side data retransmission request There is network request expense twice in library;
2) Serial No. server-side needs to dispose multiple servers to meet the High Availabitity requirement of sequence generation, therefore also Need more hardware resources.
Invention content
In view of this, the present invention provides a kind of method and system of the high performance Serial No. generation of High Availabitity, can not Server-side is needed, and final Serial No. is made to generate logic and is all placed on client;And it can ensure that Serial No. generates High Availabitity and high-performance.
To achieve the above object, according to an aspect of the invention, there is provided a kind of high performance Serial No. of High Availabitity The method of generation.
A kind of method of the high performance Serial No. generation of High Availabitity of the present invention includes:Step 1:Client is according to number Word sequence of requests, obtains Serial No. from memory queue, if there are Serial No.s in memory queue, directly returns to the number Word sequence if there is no Serial No.s in memory queue, continues to execute step 2;Step 2:The client call bottom Sequence generator generates bottom sequence;Step 3:The client generates several digital sequences based on the bottom sequence Row;Step 4:The Serial No. to rank the first is returned, and remaining Serial No. is stored in memory queue, to be directed to Following digital sequence of requests obtains Serial No. in time.
Optionally, the method further includes:The request speed of the Serial No. request is detected according to predetermined period, according to The request speed calculates the Serial No. number needed in following preset time period;If the and Serial No. in memory queue Number is less than the Serial No. number needed in the following preset time period, then repeats Step 2: step 3, generates number Word sequence, and the Serial No. is preserved into memory queue, until the Serial No. number in memory queue is not less than institute State the Serial No. number needed in following preset time period.
Optionally, the step 2 further includes:According to the quantity of client, 2 are pre-setmA bottom for calling Sequence of layer generator, wherein, m is natural number;And the step 3 further includes:The client gives birth to bottom sequence generator Into bottom sequence shifted left m, then with the serial number of the bottom sequence generator into line position or operation, with utility not The uniqueness of the bottom sequence of same bottom sequence generator generation.
Optionally, the step 3 further includes:According to the demand size that Serial No. is asked, the client is preset Based on the bottom sequence, the number of the Serial No. of generation is 2nIt is a, and generate 2nA memory queue caches place value, In, n is natural number;And by the bottom sequence shifted left n, displacement bottom sequence is obtained, then by the displacement bottom Sequence is respectively with 2nA memory queue caching place value carries out position or operation, obtains 2nA Serial No..
Optionally, the method further includes:The generating state of bottom sequence generator described in the client control, if raw Into bottom sequence variation, then by the bottom sequence generator labeled as unavailable;And timing monitors the bottom sequence life It grows up to be a useful person and is marked as not available label duration, if the label duration is more than preset duration threshold value, by the bottom sequence Generator reverts to available.
To achieve the above object, according to another aspect of the present invention, a kind of high performance Serial No. of High Availabitity is provided The system of generation.
A kind of system of the high performance Serial No. generation of High Availabitity of the present invention includes client and bottom sequence generates Device, wherein:The client obtains Serial No., if in memory queue for being asked according to Serial No. from memory queue There are Serial No.s, then directly return to the Serial No., if there is no Serial No.s in memory queue, call bottom sequence Generator generates bottom sequence;Then based on the bottom sequence, several Serial No.s are generated;Return to the number to rank the first Word sequence, and remaining Serial No. is stored in memory queue, number is obtained in time to be directed to following digital sequence of requests Word sequence;The bottom sequence generator is used to generate bottom sequence.
Optionally, the client is additionally operable to:The request speed of the Serial No. request, root are detected according to predetermined period The Serial No. number needed in following preset time period is calculated according to the request speed;If the and digital sequence in memory queue Row number is less than the Serial No. number needed in the following preset time period, then repeats to call the generation of bottom sequence generator Bottom sequence then based on the bottom sequence, generates several Serial No.s, and the Serial No. is preserved to memory In queue, until the Serial No. number in memory queue is not less than the Serial No. needed in the following preset time period Number.
Optionally, the system is additionally operable to:According to the quantity of the client, 2 are pre-setmIt is a for calling Bottom sequence generator, wherein, m is natural number;And the client by the bottom sequence that bottom sequence generator generates to Shift left m, is then given birth to the serial number of the bottom sequence generator into line position or operation with the different bottom sequence of utility Grow up to be a useful person generation bottom sequence uniqueness.
Optionally, the client is additionally operable to:According to the demand size that Serial No. is asked, preset with the bottom Based on sequence, the number of the Serial No. of generation is 2nIt is a, and generate 2nA memory queue caches place value, wherein, n is nature Number;And by the bottom sequence shifted left n, obtain displacement bottom sequence, then by the displacement bottom sequence respectively with 2nA memory queue caching place value carries out position or operation, obtains 2nA Serial No..
Optionally, the system is additionally operable to:The generating state of bottom sequence generator described in the client control, if raw Into bottom sequence variation, then by the bottom sequence generator labeled as unavailable;And timing monitors the bottom sequence life It grows up to be a useful person and is marked as not available label duration, if the label duration is more than preset duration threshold value, by the bottom sequence Generator reverts to available.
To achieve the above object, in accordance with a further aspect of the present invention, the high performance digital sequence of another High Availabitity is provided The system of column-generation.
The system of another High Availabitity high performance Serial No. generation of the present invention, including memory and processor, In:The memory is for storing instruction;The High Availabitity that the processor is configured as performing the present invention according to described instruction is high The method of the Serial No. generation of performance.
According to the technique and scheme of the present invention, by the case where not needing to server-side, by the generation logic of Serial No. Client all is placed on, so as to be reduced as far as the configuration of network request expense and hardware resource;By according to client The quantity at end, pre-sets 2mA bottom sequence generator for calling, so as to ensure Serial No. generation High Availabitity requirement;By the demand size asked according to Serial No., client is preset based on bottom sequence, generation 2nA Serial No., so as to ensure the high-performance of Serial No. generation;By the generation shape for monitoring bottom sequence generator Condition, and the available or unavailable label of adjustment bottom sequence generator in time, so as to unavailable in bottom sequence generator When it is removed from freelist in time, so as to ensure Serial No. generation High Availabitity and high-performance.
Description of the drawings
Attached drawing does not form inappropriate limitation of the present invention for more fully understanding the present invention.Wherein:
Fig. 1 is the schematic diagram of the logical architecture of the generation method of prior art digital sequence;
Fig. 2 is showing for the key step of the method for the high performance Serial No. generation of High Availabitity according to embodiments of the present invention It is intended to;
Fig. 3 is showing for the logical architecture of the method for the high performance Serial No. generation of High Availabitity according to embodiments of the present invention It is intended to;
Fig. 4 is the signal of the main flow of the method for the high performance Serial No. generation of High Availabitity of the embodiment of the present invention Figure;
Fig. 5 is that the high-performance security mechanism of the method for the high performance Serial No. generation of High Availabitity of the embodiment of the present invention is shown It is intended to;
Fig. 6 is the High Availabitity security mechanism of the method for the high performance Serial No. generation of High Availabitity of the embodiment of the present invention Schematic diagram;
Fig. 7 is a kind of showing for the major part of the system of the high performance Serial No. generation of High Availabitity of the embodiment of the present invention It is intended to;
Fig. 8 is showing for the major part of the system of the high performance Serial No. generation of another High Availabitity of the embodiment of the present invention It is intended to.
Specific embodiment
It explains below in conjunction with attached drawing to the exemplary embodiment of the present invention, including the various of the embodiment of the present invention Details should think them only exemplary to help understanding.Therefore, those of ordinary skill in the art should recognize It arrives, various changes and modifications can be made to the embodiments described herein, without departing from scope and spirit of the present invention.Together For clarity and conciseness, the description to known function and structure is omitted in sample in following description.
The technical solution of the high performance Serial No. generation of High Availabitity of the embodiment of the present invention is essentially consisted in by moving twice Position mode simultaneously does position or operation acquisition Serial No., on the basis of High Availabitity is ensured, ensures the uniqueness of Serial No.;In visitor In the end memory queue of family by it is asynchronous generate and cache part number sequence, so as to be improved performance;It is supervised by background thread The availability of rear end generator that sequence generation relies on is controlled, so as to remove unavailable sequence generation when generator is unavailable Device node;In addition, not needing to server-side during formation sequence of the embodiment of the present invention, the primary network expense of Serial No. generation is saved With the hardware cost for building server-side needs.
Fig. 2 is showing for the key step of the method for the high performance Serial No. generation of High Availabitity according to embodiments of the present invention It is intended to.
As shown in Fig. 2, a kind of method of the high performance Serial No. generation of High Availabitity of the embodiment of the present invention mainly includes Following steps:
Step 1:Client is asked according to Serial No., and Serial No. is obtained from memory queue, if being deposited in memory queue In Serial No., then the Serial No. is directly returned to, if there is no Serial No.s in memory queue, continue to execute step Two.
Step 2:The client call bottom sequence generator generates bottom sequence.
Step 3:The client generates several Serial No.s based on the bottom sequence.
Step 4:The Serial No. to rank the first is returned, and remaining Serial No. is stored in memory queue, so as to Serial No. is obtained in time for following digital sequence of requests.
Client is asked according to Serial No., directly returns to memory team during use if having Serial No. in memory queue Otherwise value in row calls bottom sequence generator generation bottom sequence, and does position or operation, generate set of number sequence, return Return first, it is remaining to be put into memory queue.
In the embodiment of the present invention, client can be additionally used in asynchronous generation Serial No., then put the Serial No. of production Enter memory queue, to be directed to following digital sequence of requests, Serial No. can be obtained from memory queue in time.Specifically such as Under:The request speed of digital sequence of requests is detected according to predetermined period (such as can be, but not limited to be every 10ms), according to request Speed calculates in following preset time period the Serial No. number that (such as can be, but not limited to be every 10ms) needs.If memory team Serial No. number in row is less than the Serial No. number needed in the following preset time period calculated, then repeats to call bottom Sequence of layer generator generates bottom sequence, then based on the bottom sequence, generates several Serial No.s, and by generation Serial No. is preserved into memory queue, until the Serial No. number in memory queue is not less than the following preset time period The Serial No. number of interior needs.In this way, can ensure can timely ask from memory queue to number in step 1 Sequence.
In addition, in the embodiment of the present invention, in order to ensure the High Availabitity of Serial No. generation, the step 2 may also include: According to the quantity of client, 2 are pre-setmA bottom sequence generator for calling, m is natural number;It is and corresponding , it may also include in the step 3:Bottom sequence the shifted left m, Ran Houyu that client generates bottom sequence generator The serial number of the bottom sequence generator is into line position or operation, the bottom generated with the different bottom sequence generator of utility The uniqueness of sequence.
In order to ensure the high-performance of Serial No. generation, in the embodiment of the present invention, step 3 may also include:According to digital sequence The demand size of request is arranged, client is preset based on the bottom sequence that bottom sequence generator generates, and is generated Serial No. number be 2nIt is a, and generate 2nA memory queue caching place value is spare, wherein, n is natural number;Next, into Row is based on bottom sequence, the conversion to several Serial No.s:By bottom sequence shifted left n, displacement bottom sequence is obtained, Then by the displacement bottom sequence respectively with 2nA memory queue caching place value carries out position or operation, obtains 2nA Serial No.. In this way, it can realize according to a bottom sequence, generation 2nA Serial No., so as to meet higher performance requirement.
In addition, the method for the high performance Serial No. generation of the High Availabitity of the embodiment of the present invention may also include to bottom sequence The monitoring of the generating state of generator:The generating state of bottom sequence generator described in client control, if generation bottom sequence It is abnormal, then by the bottom sequence generator labeled as unavailable;And timing monitors the bottom sequence generator and is labeled For not available label duration, if the label duration is more than preset duration threshold value, the bottom sequence generator is restored It is available.In this way, the high-performance of sequence generation can be ensured, while avoid the unnecessary occupancy to resource.
Fig. 3 is showing for the logical architecture of the method for the high performance Serial No. generation of High Availabitity according to embodiments of the present invention It is intended to.
As shown in figure 3, the embodiment of the present invention Serial No. generation be to be initiated by client, directly by database its His bottom sequence generator obtains sequential value, and high-performance and High Availabitity are ensured in client-side program.
In the embodiment of the present invention, in client Serial No. generation and preservation be based on memory queue, memory queue, As its name suggests, be the queue based on memory, for storing the Serial No. that is generated in advance, a kind of its first in first out based on memory Data structure.
The bottom sequence generator of the embodiment of the present invention is based on database either Redis cachings or other sequences generation Middleware.Wherein, database is using relevant database, such as, but not limited to MySQL, can use it from the spy added Property or point library divide after table from the partial value for increasing ID and coming formation sequence;Redis is cached:It is a kind of caching system, uses it INCR orders are come for generating Serial No..
Serial No. generting machanism in the embodiment of the present invention is the bottom sequence generated with bottom sequence generator Based on, generate several Serial No.s.It is specific as follows:
1. previously according to client number how much, be set with 2mA bottom sequence generator participates in the life of bottom sequence Into the purpose of this setting is to ensure the High Availabitity of Serial No. generation.
Then using each bottom sequence generator (as based on database, Redis cachings) generation bottom sequence, by bottom sequence It arranges and is handled as the basis of the Serial No. ultimately generated:Then shifted left m asks position with the serial number of the sequence generator Or, ensure that different bottom sequence generators generate the uniqueness of bottom sequence by position or operation.
2. after generating bottom sequence, further converted in client, obtain Serial No..First, root is pre-set According to a bottom sequence, the final Serial No. generated in memory is 2nIt is a.The purpose set in this way is to ensure number The high-performance of sequence generation.
Then using the bottom sequence generated in 1 as basic sequence, shifted left n generations shift bottom sequence, referred to as " x ", and 2 are generated in memory automaticallynA number is as memory cache position, such as [0,2n), i.e., from 0,1 ..., 2n- 1 2nA number, then by 2nA and x obtains 2 into line position or operationnA Serial No., the number that then will either synchronously or asynchronously generate Sequence is put into memory queue.So far, the performance for improving generation Serial No. can be realized.
In addition, in the embodiment of the present invention, client can also be used to monitor the availability of bottom sequence generator, unavailable When (bottom sequence generator depends on database or Redis, is the operation of across a network, if serviced where database/Redis Device is delayed, and there are problems for machine or network, then can cause unavailable) the bottom sequence generator can be removed from freelist, remove bottom Unavailable bottom generator can be recorded in memory after sequence of layer, after a period of time (such as can be, but not limited to be 5 minutes Unusual sequences generator can be restored to freelist afterwards), to ensure that sequence systematic function is High Availabitity.
Fig. 4 is the signal of the main flow of the method for the high performance Serial No. generation of High Availabitity of the embodiment of the present invention Figure.
As shown in figure 4, in the embodiment of the present invention, client can realize high-performance and high availability mechanism, to ensure number The performance of sequence generation.
High-performance security mechanism:
For asynchronous formation sequence, and it is put into memory queue.In use, if having digital value sequence in memory queue The digital value sequence in memory queue is directly returned, otherwise calls bottom sequence generator generation bottom sequence, and do position or fortune It calculates, generates set of number sequence, return first is remaining to be put into memory queue.
High Availabitity security mechanism:
One freelist of High Availabitity security mechanism internal maintenance includes more than two bottom sequences in freelist The information of generator when generating Serial No., first passes through bottom sequence generator and obtains a bottom sequence, then by bottom Sequence and position or operation are done with the serial number of this bottom sequence generator, obtain Serial No.;In addition, calling the generation of bottom sequence When device generates bottom sequence, it is abnormal to detect generation, can be by from available column in case of the abnormal bottom sequence generator that then corresponds to It is removed in table.For example, if generation bottom sequence is overtime 3 times (number can configure, and be not limited to 3, time-out time can configure), then It can be removed from freelist, be added to abnormal bottom sequence generator list;There is background thread asynchronous computing exception simultaneously The time for being added to abnormal bottom sequence generator list of bottom sequence generator, more than 5 minutes, (time can configure, unlimited In 5 minutes) after abnormal bottom sequence generator can be reentered into freelist, with ensure bottom sequence generator restore It can be timely used when available.
Bottom sequence generator:
For generating bottom sequence, can row be based on from increasing ID or relevant database by relevant database Value adds 1 or is the generation bottom sequence such as INCR orders of Redis.
The flow chart of specific number sequence generation sees Fig. 4.
Fig. 5 is that the high-performance security mechanism of the method for the high performance Serial No. generation of High Availabitity of the embodiment of the present invention is shown It is intended to.
As shown in figure 5, high-performance security mechanism includes the following steps:
During step 1. client terminal start-up, start background thread;
Step 2. background thread is every such as, but not limited to 10ms (time can configure), the speed of cycle calculations sequence of requests Degree;
Step 3. background thread is every the following such as, but not limited to 10ms of such as, but not limited to 5ms (time can configure) generations The Serial No. that (time can configure) needs, and the Serial No. of generation is put into memory queue;If it is pre-set every 5ms generation Serial No.s still can not meet the Serial No. demand in following default 10ms, then can further shorten 5ms's Time interval improves generation frequency, with the total amount of the Serial No. of increase generation, is used for following 10ms.If but up to 5ms's Time interval shorten to generate example every 0ms, i.e., continuously carries out the generation of Serial No., can not still meet future Serial No. demand in preset time period then increases the number of generation thread.
The high-performance security mechanism of the embodiment of the present invention not only includes generating several numbers according to a bottom sequence as a result, The high-performance of sequence, may also include:The speed of digital sequence of requests is detected by timing, following one section is calculated according to the speed Then the Serial No. number needed in time, such as 10ms checks whether Serial No. number is enough in memory queue.If no It is enough, then bottom data is obtained from bottom sequence generator, be then based on a bottom data generation 2mA Serial No..If It is still not enough, then continue to obtain bottom data, make until the Serial No. in memory queue can reach estimated in following 10ms Dosage, so as to ensure high-performance.
But based on abovementioned steps 3 " background thread is following for example every such as, but not limited to 5ms (time can configure) generations But the Serial No. of 10ms (time can configure) needs is not limited to, and the Serial No. of generation is put into memory queue ", it can still deposit The situation of nil sequence in memory queue described in earlier figures 4 is the number because required in following preset time period Sequence is generated according to current detection speed, but speed may be asked to increase sharply in following preset time period, leads to the number of generation Word sequence is still not enough.This just needs again to call bottom sequence generator, generates bottom sequence, and be converted into several numbers Sequence.
Fig. 6 is the High Availabitity security mechanism of the method for the high performance Serial No. generation of High Availabitity of the embodiment of the present invention Schematic diagram.
As shown in fig. 6, High Availabitity security mechanism includes the following steps:
During step 1. client terminal start-up, start background thread;
Step 2. background thread is abnormal every the abnormal bottom sequence generator of (configurable) inspections of such as, but not limited to 10ms Not available label duration is marked as after generation, if label duration is more than that (interval can match in such as, but not limited to 5 minutes Put) after, then restore in this bottom sequence generator to freelist.Abnormal herein, can refer to the server machine of delaying leads to exception, magnetic Disk space deficiency leads to situations such as abnormal, one bottom sequence time of generation is long, meets one of them and is judged as exception;
Step 3. background thread is every (configurable) the abnormal feelings for checking bottom sequence generator of such as, but not limited to 10ms Condition, if there is exception, such as expired times are more than 3 times (number can configure), and item number is more than etc. in currently available list In 2, then using this bottom sequence generator as abnormal bottom sequence generator labeled as unavailable.
The method of the high performance Serial No. generation of High Availabitity according to embodiments of the present invention can be seen that by being not required to In the case of wanting server-side, the generation logic of Serial No. is all placed on client, so as to be reduced as far as network Ask the configuration of expense and hardware resource;By the quantity according to client, 2 are pre-setmA bottom for calling Sequence generator, so as to ensure the High Availabitity requirement of Serial No. generation;It is big by the demand asked according to Serial No. Small, client is preset based on bottom sequence, generation 2nA Serial No., so as to ensure Serial No. generation High-performance;By monitoring the generating state of bottom sequence generator, and adjustment bottom sequence generator available or can not in time With label, so as in time remove it from freelist when bottom sequence generator is unavailable, so as to ensure The High Availabitity and high-performance of Serial No. generation.
Fig. 7 is a kind of showing for the major part of the system of the high performance Serial No. generation of High Availabitity of the embodiment of the present invention It is intended to.
As shown in fig. 7, a kind of system 70 of the high performance Serial No. generation of High Availabitity of the embodiment of the present invention includes visitor Family end 701 and bottom sequence generator 702, wherein:Client 701 obtains for being asked according to Serial No. from memory queue Serial No. is taken, if there are Serial No.s in memory queue, the Serial No. is directly returned to, if being not present in memory queue Serial No. then calls bottom sequence generator 702 to generate bottom sequence;Then based on the bottom sequence, if generation Dry Serial No.;The Serial No. to rank the first is returned, and remaining Serial No. is stored in memory queue, to be directed to Following digital sequence of requests obtains Serial No. in time;Bottom sequence generator 702 is used to generate bottom sequence.
Client 701 can be additionally used in:The request speed of the Serial No. request is detected according to predetermined period, according to described Request speed calculates the Serial No. number needed in following preset time period;If the and Serial No. number in memory queue Less than the Serial No. number needed in the following preset time period, then repeat that bottom sequence generator 702 is called to generate bottom Sequence of layer then based on the bottom sequence, generates several Serial No.s, and the Serial No. is preserved to memory team In row, until the Serial No. number in memory queue is not less than the Serial No. needed in the following preset time period Number.
In the embodiment of the present invention, system 70 can be additionally used in:According to the quantity of client 701,2 are pre-setmIt is a can For the bottom sequence generator 702 of calling;And the correspondingly, bottom sequence that client 701 generates bottom sequence generator 702 Row shifted left m, then with the serial number of the bottom sequence generator 702 into line position or operation, with the different bottom of utility The uniqueness for the bottom sequence that sequence of layer generator 702 generates.
In addition, client 701 can be additionally used in:According to the demand size that Serial No. is asked, preset with the bottom Based on sequence, the number of the Serial No. of generation is 2nIt is a, and generate 2nA memory queue caches place value;And by the bottom Sequence of layer shifted left n obtains displacement bottom sequence, then by the displacement bottom sequence respectively with 2nA memory queue caching Place value obtains 2 into line position or operationnA Serial No..
In the embodiment of the present invention, system 70 is additionally operable to:Client 701 monitors the generation of the bottom sequence generator 702 Situation, if generation bottom sequence variation, by the bottom sequence generator 702 labeled as unavailable;And timing monitoring institute It states bottom sequence generator 702 and is marked as not available label duration, if the label duration is more than preset duration threshold value, The bottom sequence generator 702 is reverted to available.
Fig. 8 is showing for the major part of the system of the high performance Serial No. generation of another High Availabitity of the embodiment of the present invention It is intended to.
A kind of system 80 of the high performance Serial No. generation of High Availabitity of the embodiment of the present invention includes memory 801 and place Device 802 is managed, wherein:Memory 801 is for storing instruction;Processor 802 is configured as performing the present invention in fact according to described instruction The method for applying the high performance Serial No. generation of High Availabitity of example.
From the above, it can be seen that by the case where not needing to server-side, the generation logic of Serial No. is complete Portion is placed on client, so as to be reduced as far as the configuration of network request expense and hardware resource;By according to client Quantity, pre-set 2mA bottom sequence generator for calling, so as to ensure the height of Serial No. generation Requirement can be used;By the demand size asked according to Serial No., client is preset based on bottom sequence, generation 2n A Serial No., so as to ensure the high-performance of Serial No. generation;By monitoring the generating state of bottom sequence generator, And the available or unavailable label of adjustment bottom sequence generator in time, so as to when bottom sequence generator is unavailable and When it is removed from freelist, so as to ensure Serial No. generation High Availabitity and high-performance.
Above-mentioned specific embodiment, does not form limiting the scope of the invention.Those skilled in the art should be bright It is white, depending on design requirement and other factors, various modifications, combination, sub-portfolio and replacement can occur.It is any Modifications, equivalent substitutions and improvements made within the spirit and principles in the present invention etc., should be included in the scope of the present invention Within.

Claims (11)

  1. A kind of 1. method of the high performance Serial No. generation of High Availabitity, which is characterized in that including:
    Step 1:Client is asked according to Serial No., and Serial No. is obtained from memory queue, if there are numbers in memory queue Word sequence then directly returns to the Serial No., if there is no Serial No.s in memory queue, continues to execute step 2;
    Step 2:The client call bottom sequence generator generates bottom sequence;
    Step 3:The client generates several Serial No.s based on the bottom sequence;
    Step 4:The Serial No. to rank the first is returned, and remaining Serial No. is stored in memory queue, to be directed to Following digital sequence of requests obtains Serial No. in time.
  2. 2. according to the method described in claim 1, it is characterized in that, the method further includes:
    The request speed of the Serial No. request is detected according to predetermined period, when calculating following default according to the request speed Between the Serial No. number that needs in section;And
    If the Serial No. number in memory queue is less than the Serial No. number needed in the following preset time period, weigh It is multiple to perform Step 2: step 3, generates Serial No., and the Serial No. is preserved into memory queue, until memory team Serial No. number in row is not less than the Serial No. number needed in the following preset time period.
  3. 3. according to the method described in claim 1, it is characterized in that,
    The step 2 further includes:According to the quantity of client, 2 are pre-setmA bottom sequence for calling generates Device, wherein, m is natural number;And
    The step 3 further includes:Bottom sequence the shifted left m, Ran Houyu that the client generates bottom sequence generator The serial number of the bottom sequence generator is into line position or operation, the bottom generated with the different bottom sequence generator of utility The uniqueness of sequence.
  4. 4. according to the method described in claim 1, it is characterized in that, the step 3 further includes:
    According to the demand size that Serial No. is asked, the client is preset based on the bottom sequence, generation The number of Serial No. is 2nIt is a, and generate 2nA memory queue caches place value, wherein, n is natural number;And
    By the bottom sequence shifted left n, displacement bottom sequence is obtained, then by the displacement bottom sequence respectively with 2nIt is a Memory queue caching place value carries out position or operation, obtains 2nA Serial No..
  5. 5. according to the method described in claim 1, it is characterized in that, the method further includes:
    The generating state of bottom sequence generator described in the client control, if generation bottom sequence variation, by the bottom Sequence of layer generator is labeled as unavailable;And
    Timing monitors the bottom sequence generator and is marked as not available label duration, if the label duration is more than default Duration threshold value then reverts to the bottom sequence generator available.
  6. 6. a kind of system of the high performance Serial No. generation of High Availabitity, which is characterized in that given birth to including client and bottom sequence It grows up to be a useful person, wherein:
    The client obtains Serial No., if existing in memory queue for being asked according to Serial No. from memory queue Serial No. then directly returns to the Serial No., if there is no Serial No.s in memory queue, bottom sequence is called to generate Device generates bottom sequence;Then based on the bottom sequence, several Serial No.s are generated;Return to the digital sequence to rank the first Row, and remaining Serial No. is stored in memory queue, digital sequence is obtained in time to be directed to following digital sequence of requests Row;
    The bottom sequence generator is used to generate bottom sequence.
  7. 7. system according to claim 6, which is characterized in that the client is additionally operable to:
    The request speed of the Serial No. request is detected according to predetermined period, when calculating following default according to the request speed Between the Serial No. number that needs in section;And
    If the Serial No. number in memory queue is less than the Serial No. number needed in the following preset time period, weigh Polyphony generates bottom sequence with bottom sequence generator, then based on the bottom sequence, generates several Serial No.s, and The Serial No. is preserved into memory queue, until the Serial No. number in memory queue is following default not less than described The Serial No. number needed in period.
  8. 8. system according to claim 6, which is characterized in that the system is additionally operable to:
    According to the quantity of the client, 2 are pre-setmA bottom sequence generator for calling, wherein, m is nature Number;And
    Then the bottom sequence shifted left m that the client generates bottom sequence generator is generated with the bottom sequence The serial number of device is into line position or operation, the uniqueness of bottom sequence generated with the different bottom sequence generator of utility.
  9. 9. system according to claim 6, which is characterized in that the client is additionally operable to:
    According to the demand size that Serial No. is asked, preset based on the bottom sequence, the Serial No. of generation Number is 2nIt is a, and generate 2nA memory queue caches place value, wherein, n is natural number;And
    By the bottom sequence shifted left n, displacement bottom sequence is obtained, then by the displacement bottom sequence respectively with 2nIt is a Memory queue caching place value carries out position or operation, obtains 2nA Serial No..
  10. 10. system according to claim 6, which is characterized in that the system is additionally operable to:
    The generating state of bottom sequence generator described in the client control, if generation bottom sequence variation, by the bottom Sequence of layer generator is labeled as unavailable;And
    Timing monitors the bottom sequence generator and is marked as not available label duration, if the label duration is more than default Duration threshold value then reverts to the bottom sequence generator available.
  11. 11. a kind of system of the high performance Serial No. generation of High Availabitity, which is characterized in that including memory and processor, In:
    The memory is for storing instruction;
    The processor is configured as performing the High Availabitity high-performance as described in any one of claim 1-5 according to described instruction Serial No. generation method.
CN201611165776.4A 2016-12-16 2016-12-16 Method and system for generating digital sequence with high availability and high performance Active CN108206744B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201611165776.4A CN108206744B (en) 2016-12-16 2016-12-16 Method and system for generating digital sequence with high availability and high performance

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611165776.4A CN108206744B (en) 2016-12-16 2016-12-16 Method and system for generating digital sequence with high availability and high performance

Publications (2)

Publication Number Publication Date
CN108206744A true CN108206744A (en) 2018-06-26
CN108206744B CN108206744B (en) 2021-09-14

Family

ID=62601384

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611165776.4A Active CN108206744B (en) 2016-12-16 2016-12-16 Method and system for generating digital sequence with high availability and high performance

Country Status (1)

Country Link
CN (1) CN108206744B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102999525A (en) * 2011-09-16 2013-03-27 深圳市金蝶中间件有限公司 Data-table processing method and system
US20140143156A1 (en) * 1998-03-25 2014-05-22 Digital-Vending Services International, Llc Computer architecture for managing courseware in a shared use operating environment
CN103914720A (en) * 2013-01-08 2014-07-09 广州宽度信息技术有限公司 Two-dimension code image encryption system and two-dimension code image generation method
CN104850619A (en) * 2015-05-15 2015-08-19 深圳市金蝶友商电子商务服务有限公司 Receipt code generation method and apparatus
CN105139060A (en) * 2015-09-15 2015-12-09 歌尔声学股份有限公司 Generation and testing method and system of bar codes based on a plurality of print devices

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140143156A1 (en) * 1998-03-25 2014-05-22 Digital-Vending Services International, Llc Computer architecture for managing courseware in a shared use operating environment
CN102999525A (en) * 2011-09-16 2013-03-27 深圳市金蝶中间件有限公司 Data-table processing method and system
CN103914720A (en) * 2013-01-08 2014-07-09 广州宽度信息技术有限公司 Two-dimension code image encryption system and two-dimension code image generation method
CN104850619A (en) * 2015-05-15 2015-08-19 深圳市金蝶友商电子商务服务有限公司 Receipt code generation method and apparatus
CN105139060A (en) * 2015-09-15 2015-12-09 歌尔声学股份有限公司 Generation and testing method and system of bar codes based on a plurality of print devices

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
LEO$SUN: "分布式序列生成器", 《CSDN,HTTPS://BLOG.CSDN.NET/PANAMERA_TURBO/ARTICLE/DETAILS/53317340》 *

Also Published As

Publication number Publication date
CN108206744B (en) 2021-09-14

Similar Documents

Publication Publication Date Title
CN108388479B (en) Delayed message pushing method and device, computer equipment and storage medium
CN106598705B (en) Asynchronous task scheduling method, device and system and electronic equipment
CN102629219B (en) Reduce in parallel computation frame holds adaptive load balancing method
US9560165B2 (en) BT offline data download system and method, and computer storage medium
CN104754036A (en) Message processing system and processing method based on kafka
CN104731956A (en) Method and system for synchronizing data and related database
CN109246229A (en) A kind of method and apparatus of distribution resource acquisition request
CN105808736B (en) A kind of list data-updating method, apparatus and system
CN104598563A (en) High concurrency data storage method and device
CN103516807A (en) Cloud computing platform server load balancing system and method
CN106021468B (en) The update method and system of distributed caching and local cache
CN105446893A (en) Data storage method and device
CN104202423A (en) System for extending caches by aid of software architectures
CN105843819B (en) Data export method and device
CN111737327A (en) Automobile production action data acquisition method, system, device and storage medium
CN110309230A (en) Block generation method, device, equipment and storage medium based on block chain
CN105095299A (en) Picture capturing method and system
CN104125303B (en) Reading and writing data requesting method, client and system
CN110099084A (en) A kind of method, system and computer-readable medium guaranteeing storage service availability
CN107678923A (en) A kind of optimization method of distributed file system Message Processing
CN107646105B (en) Cloud computing infrastructure
CN115587118A (en) Task data dimension table association processing method and device and electronic equipment
CN105915626A (en) Data copy initial placement method for cloud storage
CN104063468A (en) Data report automatic generating and extracting method and device
CN105183582B (en) Data back up method and device

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