CN113495888A - Identification management method and device - Google Patents

Identification management method and device Download PDF

Info

Publication number
CN113495888A
CN113495888A CN202010259314.9A CN202010259314A CN113495888A CN 113495888 A CN113495888 A CN 113495888A CN 202010259314 A CN202010259314 A CN 202010259314A CN 113495888 A CN113495888 A CN 113495888A
Authority
CN
China
Prior art keywords
identifier
value
number segment
segment
main
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
CN202010259314.9A
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.)
Beijing Jingdong Shangke Information Technology Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Original Assignee
Beijing Jingdong Shangke Information Technology Co Ltd
Beijing Wodong Tianjun 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 Shangke Information Technology Co Ltd, Beijing Wodong Tianjun Information Technology Co Ltd filed Critical Beijing Jingdong Shangke Information Technology Co Ltd
Priority to CN202010259314.9A priority Critical patent/CN113495888A/en
Publication of CN113495888A publication Critical patent/CN113495888A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • 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
    • 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/23Updating
    • 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/24Querying
    • G06F16/245Query processing
    • G06F16/2458Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
    • G06F16/2474Sequence data queries, e.g. querying versioned data

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Software Systems (AREA)
  • Fuzzy Systems (AREA)
  • Mathematical Physics (AREA)
  • Probability & Statistics with Applications (AREA)
  • Computational Linguistics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses an identification management method and device, and relates to the technical field of computers. One embodiment of the method comprises: receiving an identification obtaining request, and obtaining and feeding back an identification from a standby number section if the residual quantity of the current identification in the main number section is less than or equal to a first numerical value; in the process of feeding back the identifier, if the residual amount of the identifier in the standby number segment is judged to be less than or equal to a second numerical value, the loading operation of the identifier in the main number segment is triggered, so that the identifier is extracted from a database and is stored in the main number segment. The embodiment adopts a main and standby mode, when the residual quantity of the ID in one number section is small, the other number section is triggered to load the ID, the number section is directly switched to be processed when no ID is available, and the high efficiency and the continuity of ID acquisition are ensured through the mode of loading and using the ID by the main and standby number sections in turn.

Description

Identification management method and device
Technical Field
The present invention relates to the field of computer technologies, and in particular, to an identifier management method and apparatus.
Background
At present, more and more systems adopt a distributed management mode, and with the continuous improvement of the complexity of the systems, unique identifiers need to be set in many scenes, such as order numbers in an order system, coupon numbers in a coupon system, express delivery order numbers in warehouse logistics, and the like. The current way to obtain the identity is as follows:
1. setting a self-increment identification in a database, and generating a non-repeated and continuous self-increment identification;
2. creating a permanent sequential node in zookeeper is utilized to ensure that a unique identifier is generated for each call.
In the process of implementing the present invention, the inventor finds that none of the existing methods can meet the requirements of distributed, highly concurrent, continuously incremental and infinitely obtaining identifiers:
1. the first mode is highly dependent on the stability of the database, and each query needs to start the connection with the database first, so that the timeliness is poor. A large number of links may be occupied under high concurrency conditions, resulting in a database being down and unavailable;
2. the second mode has more complicated operation steps, needs frequent locking and has larger influence on the performance of the system under the high concurrency state.
Disclosure of Invention
In view of this, embodiments of the present invention provide an identifier management method and apparatus, which can at least solve a phenomenon that ID acquisition is not suitable for a high-concurrency scenario in the prior art.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided an identifier management method including:
receiving an identification obtaining request, and obtaining and feeding back an identification from a standby number section if the residual quantity of the current identification in the main number section is less than or equal to a first numerical value;
in the process of feeding back the identifier, if the residual amount of the identifier in the standby number segment is judged to be less than or equal to a second numerical value, the loading operation of the identifier in the main number segment is triggered, so that the identifier is extracted from a database and is stored in the main number segment.
Optionally, before the receiving the identifier obtaining request, the method further includes:
responding to the starting operation of the identification generation system, and acquiring a starting value of the identification in the current database; wherein the identification in the database is continuous and incremental;
determining the consumption of the mark within a preset time according to the consumption rate of the mark in the main number section, and taking the sum of the initial value and the consumption as an ending value of the mark;
and extracting the identifiers in the interval of the starting value and the ending value from the database and storing the identifiers in the main number segment.
Optionally, before determining the consumption of the identifier within a predetermined time period according to the consumption rate identified in the primary number segment, the method further includes: and counting the first consumption identified in the primary number section within a preset historical time length, and taking the quotient of the first consumption and the preset historical time length as the consumption rate.
Optionally, before obtaining the identifier from the standby number segment and feeding back the identifier if the remaining amount of the current identifier in the primary number segment is less than or equal to the first numerical value, the method further includes: if the residual amount of the mark in the main number section is less than or equal to a third numerical value, extracting the mark from the main number section, feeding back the mark, and triggering the loading operation of the mark in the standby number section; wherein the third value is greater than the first value.
Optionally, the triggering the loading operation on the identifier in the spare number segment includes:
acquiring a first initial value of the current identifier of the database; wherein the first start value is located after and adjacent to the end value;
according to the consumption rate of the marks in the spare number segment, second consumption of the marks in a first preset time length is obtained, and then the sum of the first initial value and the second consumption is used as a first termination value of the marks;
and extracting identifications positioned in the first starting value interval and the first ending value interval from the database and storing the identifications into the spare number segment.
Optionally, the obtaining the identifier from the spare number segment and feeding back the identifier includes: and according to the sequence from the first initial value to the first termination value, acquiring and feeding back the identifier of the current first sequence in the spare number segment, and then deleting the fed identifier.
Optionally, after the triggering the load operation on the identifier in the primary number segment, the method further includes: if the residual quantity of the identification in the standby number section is less than or equal to a fourth numerical value, switching to the main number section to process the identification acquisition request; wherein the second value is greater than the fourth value.
Optionally, the method further includes:
when the main number segment is monitored to be abnormal, switching to the standby number segment to process the identifier acquisition request; and
and when the standby number segment is monitored to be abnormal, switching to the main number segment to process the identifier acquisition request.
To achieve the above object, according to another aspect of the embodiments of the present invention, there is provided an identifier management apparatus including:
the switching module is used for receiving the identifier acquisition request, and acquiring the identifier from the standby number section and feeding back the identifier if the residual quantity of the current identifier in the main number section is less than or equal to a first numerical value;
and the loading module is used for triggering the loading operation of the identifier in the main number segment if the residual quantity of the identifier in the standby number segment is judged to be less than or equal to a second numerical value in the identifier feedback process so as to extract the identifier from a database and store the identifier in the main number segment.
Optionally, the system further includes an initialization module, configured to:
responding to the starting operation of the identification generation system, and acquiring a starting value of the identification in the current database; wherein the identification in the database is continuous and incremental;
determining the consumption of the mark within a preset time according to the consumption rate of the mark in the main number section, and taking the sum of the initial value and the consumption as an ending value of the mark;
and extracting the identifiers in the interval of the starting value and the ending value from the database and storing the identifiers in the main number segment.
Optionally, the initialization module is further configured to: and counting the first consumption identified in the primary number section within a preset historical time length, and taking the quotient of the first consumption and the preset historical time length as the consumption rate.
Optionally, the system further includes a spare number segment loading module, configured to: if the residual amount of the mark in the main number section is less than or equal to a third numerical value, extracting the mark from the main number section, feeding back the mark, and triggering the loading operation of the mark in the standby number section; wherein the third value is greater than the first value.
Optionally, the spare number segment loading module is configured to:
acquiring a first initial value of the current identifier of the database; wherein the first start value is located after and adjacent to the end value;
according to the consumption rate of the marks in the spare number segment, second consumption of the marks in a first preset time length is obtained, and then the sum of the first initial value and the second consumption is used as a first termination value of the marks;
and extracting identifications positioned in the first starting value interval and the first ending value interval from the database and storing the identifications into the spare number segment.
Optionally, the switching module is configured to: and according to the sequence from the first initial value to the first termination value, acquiring and feeding back the identifier of the current first sequence in the spare number segment, and then deleting the fed identifier.
Optionally, the system further includes a main number segment switching module, configured to: if the residual quantity of the identification in the standby number section is less than or equal to a fourth numerical value, switching to the main number section to process the identification acquisition request; wherein the second value is greater than the fourth value.
Optionally, the switching module further includes:
when the main number segment is monitored to be abnormal, switching to the standby number segment to process the identifier acquisition request; and
and when the standby number segment is monitored to be abnormal, switching to the main number segment to process the identifier acquisition request.
To achieve the above object, according to still another aspect of embodiments of the present invention, an identity management electronic device is provided.
The electronic device of the embodiment of the invention comprises: one or more processors; storage means for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to implement any of the above described identity management methods.
To achieve the above object, according to a further aspect of the embodiments of the present invention, there is provided a computer readable medium having stored thereon a computer program which, when executed by a processor, implements any of the above-described identity management methods.
According to the scheme provided by the invention, one embodiment of the invention has the following advantages or beneficial effects: and performing strong consistency synchronization by adopting a main/standby mode. When the residual quantity of the ID in one number section is small, the other number section is triggered to load the ID, the number section is directly switched to the other number section for processing when no ID is available, the dependency on a database is reduced through the mode that the ID is loaded and used by the main number section and the standby number section in turn, and the high efficiency and the continuity of the ID acquisition are ensured.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
fig. 1 is a schematic main flow chart of an identifier management method according to an embodiment of the present invention;
FIG. 2 is a flow diagram illustrating an alternative identifier management method according to an embodiment of the present invention;
FIG. 3 is a flowchart illustrating a specific tag management method according to an embodiment of the present invention;
FIG. 4 is a block diagram of an embodiment of a method for identity management;
FIG. 5 is a schematic diagram of the main modules of an identity management device according to an embodiment of the present invention;
FIG. 6 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
FIG. 7 is a schematic block diagram of a computer system suitable for use with a mobile device or server implementing an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
The ID may be used to identify unique information for subsequent queries, such as order numbers in an order system, may be used to query logistics information, merchandise information, and the like. The invention aims to obtain distributed high-concurrency, continuous self-increment and infinite IDs (identity) in a distributed mode, wherein:
1) self-INCREMENT (AUTO _ INCREAENT), the other meaning is that the ID is ordered, and the order number is taken as an example, so that the order quantity within a certain time can be calculated conveniently;
2) the method can obtain more IDs infinitely, the condition of ID recycling is not easy to occur, and the method does not recycle the IDs within the data range.
Referring to fig. 1, a main flowchart of an identifier management method according to an embodiment of the present invention is shown, including the following steps:
s101: receiving an identification obtaining request, and obtaining and feeding back an identification from a standby number section if the residual quantity of the current identification in the main number section is less than or equal to a first numerical value;
s102: in the process of feeding back the identifier, if the residual amount of the identifier in the standby number segment is judged to be less than or equal to a second numerical value, the loading operation of the identifier in the main number segment is triggered, so that the identifier is extracted from a database and is stored in the main number segment.
In the above embodiment, for step S101, in order to prevent time consumption caused by reading and updating the database from affecting the response speed of the service, the present invention provides an ID acquisition service by using a number segment on the basis of the database; where a number segment is a generic name for a set of spare IDs cached in a cache library (e.g., Redis).
In addition to the main number segment, the invention is also provided with a spare number segment, the IDs stored in the two segments are different, and the initial value/the end value of the IDs are adjacent, for example, the IDs in the main number segment are 1-1001, the IDs in the spare number segment are 1002-2002, then the IDs in the main number segment in the next stage are 2003-3003, and so on.
By adopting the main/standby mode, when an ID acquisition request is received, whether the request can be processed in the main number section is judged firstly, and if not, the standby number section is switched to be processed.
The number segment is mainly used for storing the ID, so that the basis for judging whether the main number segment can process the request is to judge whether the ID is stored in the main number segment:
1) if yes, extracting one ID and feeding back:
the IDs in the No. 1 section are continuous and self-increment, so that the ID of the first current sequence can be extracted according to the ID sequence mode, such as 1;
secondly, one ID can be randomly selected because the IDs in the number segments are different;
2) if not, namely the ID in the main number segment is completely consumed, the processing is switched to the standby number segment.
In the above manner, it is determined whether the ID in the main number segment is completely consumed (i.e. the first value is 0), in actual operation, the first value may also be set to other values, such as 1, 2, etc., but in order to avoid the situation that the number is too large because the ID in the number segment is not completely consumed, i.e. a new ID is loaded, the first value is usually set to 0.
In addition, when the main number section is in an abnormal state, no matter whether the ID is consumed or not, the main number section is switched to the standby number section for processing so as to extract and feed back one ID in sequence or at random.
For step S102, in order to adapt to the high concurrency condition, when the remaining amount of the ID in the number segment is small, the present invention can trigger another number segment to load the ID, so that when there is no ID in one of the number segments, the present invention can directly switch to another number segment to continue processing the ID acquisition request, thereby ensuring the uninterrupted operation of ID acquisition.
Taking the main number segment as an example, when the remaining amount of the ID is less than or equal to a third value (e.g., 400), the loading operation of the ID in the spare number segment is triggered; and for the spare number segment, when the remaining quantity of the ID is less than or equal to a second value (for example, 300, 400, which may be equal to a third value, or may not be equal to the third value), the loading operation on the ID in the main number segment is triggered.
In addition, the loading of the ID in the spare number segment is asynchronous loading, so that the congestion degree of the obtained ID is reduced, and the influence on an ID generation system is avoided.
Similarly, in the process of processing the ID acquisition request by using the spare number segment, if the remaining ID is less than or equal to the fourth value (less than the second value, usually 0), the process is directly switched to the primary number segment process. By loading and using the ID of the main and standby number segments in turn, the high efficiency and the continuity of ID acquisition are ensured.
The method provided by the above embodiment adopts the active/standby mode, and when the remaining amount of the ID in one of the number segments is small, the other number segment is triggered to load the ID, so as to ensure that the number segment is directly switched to the other number segment for processing when no ID is available, and through the manner of loading and using the ID by the active/standby number segments in turn, the dependency on the database is reduced, and the high efficiency and the continuity of ID acquisition are ensured.
Referring to fig. 2, a schematic flow chart of an optional identifier management method according to an embodiment of the present invention is shown, including the following steps:
s201: responding to the starting operation of the identification generation system, and acquiring a starting value of the identification in the current database; wherein the identities in the database are continuous and self-increasing;
s202: counting a first consumption identified in a main number section within a preset historical time length, and taking a quotient of the first consumption and the preset historical time length as the consumption rate;
s203: determining the consumption of the mark within a preset time according to the consumption rate of the mark in the main number section, and taking the sum of the initial value and the consumption as an ending value of the mark;
s204: and extracting the identifiers in the interval of the starting value and the ending value from the database and storing the identifiers in the main number segment.
In the above embodiment, for steps S201 to S203, when the ID generation system is started, the primary number segment in the number segment update module needs to initialize one segment of ID to provide the ID obtaining service, specifically:
1) querying a database (e.g., Mysql database), determining a starting value for the ID in the database, e.g., a starting value of 1;
2) the consumption rate of the IDs in the main number segment is estimated/calculated to calculate the amount of IDs that need to be consumed within a predetermined time period (or step size). For example, 100 IDs are consumed in 1 minute, and assuming that the main number segment needs to provide ID acquisition service for 10 minutes, the ID consumption amount calculated is 1000;
in addition, the ID consumption rate may be estimated according to specific traffic volume, or may be calculated according to historical data, for example, the order placing amount per minute in the order system is 200, and the consumption rate of the ID (i.e. order number) is 200 per minute.
3) Calculating the sum of the initial value and the calculated ID amount to obtain an end value;
4) and acquiring the calculated ID quantity from the database from the initial value, or extracting the ID between the initial value and the final value, and then storing the ID into the main number segment to finish the initialization operation of the main number segment ID, such as 1-1001.
Note that the ID start value in the database is updated as the ID is extracted, and for example, the start value is 1 before the ID is extracted from the major number segment, and is changed to 1002 after the extraction, indicating the ID loading cutoff position.
The above operation of loading the ID from the database is the same for the spare number segment, but the ID start value (i.e. the first start value) is located after the end value of the main number segment and adjacent to the end value, as in 1002, the spare number segment starts from 1002 when the ID is extracted.
In addition, the ID consumption rate in the spare number segment may be different from that of the main number segment, for example, the ID consumption rate in the main number segment is 100 per minute, and the spare number segment is 150 per minute, or may be set to the same consumption rate.
Similarly, the duration (i.e. the first predetermined duration) for providing the ID obtaining service by the spare number segment may also be different from the main number segment, for example, 10 minutes in the main number segment, and 8 minutes in the spare number segment, or may both be set to the same duration.
Taking the same consumption rate and the same time length as an example, the ID acquired by the primary number segment is 1-1001, and the ID acquired by the standby number segment is 1002-2002.
The method provided by the above embodiment fully considers the consumption rate of the number segment for the ID, so as to dynamically calculate the termination value of the ID in the number segment according to the consumption rate, thereby facilitating ID management and tracing.
Referring to fig. 3, a flowchart of a specific identifier management method according to an embodiment of the present invention is shown, including the following steps:
s301: responding to the starting operation of the ID generation system, and acquiring the initial value of the ID in the current database; wherein the IDs in the database are continuous and self-increasing;
s302: determining the consumption of the ID in a preset time period according to the consumption rate of the ID in the main number section, and taking the sum of the initial value and the consumption as the termination value of the ID;
s303: extracting IDs within the interval of the starting value and the ending value from a database and storing the IDs in a main number section;
s304: receiving an ID acquisition request, and judging whether the main number section is abnormal or not;
s305: if yes, switching to a standby number section to process the ID acquisition request;
s306: if not, judging whether the residual quantity of the current ID in the main number section is empty, if so, turning to the step S305;
s307: if not, extracting an ID from the residual IDs and feeding back, and judging whether the residual quantity is less than or equal to a third numerical value; wherein the third value is greater than 0;
s308: if yes, triggering loading operation of the ID in the spare number section;
s309: acquiring a first initial value of a current ID of a database; wherein the first start value is located after and adjacent to the end value;
s310: acquiring second consumption of the ID within a first preset time according to the consumption rate of the ID in the spare number segment, and taking the sum of the first initial value and the second consumption as a first termination value of the ID;
s311: extracting IDs positioned in a first starting value interval and a first ending value interval from a database and storing the IDs into a spare number segment;
s312: judging whether the residual quantity of the ID in the standby number section is less than or equal to a second numerical value or not in the process of feeding back the ID by the standby number section; wherein the second value is greater than 0;
s313: if yes, triggering the loading operation of the ID in the main number section;
s314: if not, the rest ID acquisition requests are continuously processed, and when the residual quantity of the IDs in the standby number section is 0, the ID acquisition requests are processed by switching to the main number section.
Compared with the prior art, the method provided by the embodiment of the invention has at least the following beneficial effects:
1) setting a number segment as a cache library of the ID in the database, and when receiving an ID acquisition request, firstly processing the request by using the number segment so as to reduce the dependency on the database;
2) even if the database is abnormal, the main and standby number sections can provide ID acquisition service for a period of time, so that the high availability of the whole system is ensured, and precious time is strived for system recovery;
3) in the numerical range allowed by the database, the obtained ID is infinite, and the phenomenon of repeated recycling caused by the exhausted ID is not considered;
4) only when the residual quantity of the IDs in the number segments is small, the IDs are triggered to be extracted from the database, so that the connection quantity between the IDs and the database is greatly reduced, and the database is not easy to crash and crash even if high concurrency conditions occur;
5) fully considering the consumption rate of the ID in the number segment, and realizing the dynamic management of the ID in the number segment, wherein the ID quantity stored in the number segment corresponds to the consumption rate;
6) and performing strong consistency synchronization by adopting a main/standby mode. When the residual quantity of the ID in one number section is small, the other number section is triggered to load the ID, the number section is directly switched to the other number section for processing when no ID is available, the dependency on a database is reduced through the mode that the ID is loaded and used by the main number section and the standby number section in turn, and the high efficiency and the continuity of the ID acquisition are ensured.
Referring to fig. 4, a frame diagram 400 of an identifier management method according to an embodiment of the present invention is shown, which includes the following units:
1. an acquisition ID unit: and acquiring the ID by inquiring the Redis number segment updating unit according to the specific key.
Redis is a high-performance key-value database, the key value is customized when the ID is cached to the Redis, for example, "nextId", and each time the Redis number segment updating unit is called, the Redis needs to be queried by the nextId to obtain the ID.
2. Redis number segment update unit: redis has high read-write performance, and ensures that the system can efficiently acquire the ID. The minimum QPS of the Redis standalone can reach 5W +, so the method selects a mode of inquiring the Redis to acquire the ID to support high concurrency.
3. Database number segment initial value updating unit: it is an important guarantee that the system outputs continuously increasing IDs, and the initial value is updated adaptively after each ID extraction.
Referring to fig. 5, a schematic diagram of main modules of an identifier management apparatus 500 according to an embodiment of the present invention is shown, including:
the switching module 501 is configured to receive an identifier obtaining request, and if the remaining amount of the current identifier in the primary number segment is less than or equal to a first numerical value, obtain the identifier from the standby number segment and feed back the identifier;
a loading module 502, configured to trigger a loading operation on the identifier in the primary number segment if it is determined that the remaining amount of the identifier in the standby number segment is less than or equal to a second numerical value in the identifier feedback process, so as to extract the identifier from the database and store the identifier in the primary number segment.
The device for implementing the present invention further includes an initialization module 503 (not shown in the figure) for:
responding to the starting operation of the identification generation system, and acquiring a starting value of the identification in the current database; wherein the identification in the database is continuous and incremental;
determining the consumption of the mark within a preset time according to the consumption rate of the mark in the main number section, and taking the sum of the initial value and the consumption as an ending value of the mark;
and extracting the identifiers in the interval of the starting value and the ending value from the database and storing the identifiers in the main number segment.
In the device for implementing the present invention, the initialization module 503 is further configured to:
and counting the first consumption identified in the primary number section within a preset historical time length, and taking the quotient of the first consumption and the preset historical time length as the consumption rate.
The apparatus further includes a spare number segment loading module 504 (not shown) for:
if the residual amount of the mark in the main number section is less than or equal to a third numerical value, extracting the mark from the main number section, feeding back the mark, and triggering the loading operation of the mark in the standby number section; wherein the third value is greater than the first value.
In the implementation apparatus of the present invention, the spare number segment loading module 504 is configured to:
acquiring a first initial value of the current identifier of the database; wherein the first start value is located after and adjacent to the end value;
according to the consumption rate of the marks in the spare number segment, second consumption of the marks in a first preset time length is obtained, and then the sum of the first initial value and the second consumption is used as a first termination value of the marks;
and extracting identifications positioned in the first starting value interval and the first ending value interval from the database and storing the identifications into the spare number segment.
In the device for implementing the present invention, the switching module 501 is configured to:
and according to the sequence from the first initial value to the first termination value, acquiring and feeding back the identifier of the current first sequence in the spare number segment, and then deleting the fed identifier.
The device of the present invention further includes a main number segment switching module 505 (not shown in the figure) for:
if the residual quantity of the identification in the standby number section is less than or equal to a fourth numerical value, switching to the main number section to process the identification acquisition request; wherein the second value is greater than the fourth value.
In the device for implementing the present invention, the switching module 505 further includes:
when the main number segment is monitored to be abnormal, switching to the standby number segment to process the identifier acquisition request; and
and when the standby number segment is monitored to be abnormal, switching to the main number segment to process the identifier acquisition request.
In addition, the detailed implementation of the device in the embodiment of the present invention has been described in detail in the above method, so that the repeated description is not repeated here.
FIG. 6 illustrates an exemplary system architecture 600 to which embodiments of the invention may be applied.
As shown in fig. 6, the system architecture 600 may include terminal devices 601, 602, 603, a network 604, and a server 605 (by way of example only). The network 604 serves to provide a medium for communication links between the terminal devices 601, 602, 603 and the server 605. Network 604 may include various types of connections, such as wire, wireless communication links, or fiber optic cables, to name a few.
A user may use the terminal devices 601, 602, 603 to interact with the server 605 via the network 604 to receive or send messages or the like. Various communication client applications can be installed on the terminal devices 601, 602, 603.
The terminal devices 601, 602, 603 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 605 may be a server providing various services, such as a background management server (for example only) providing support for shopping websites browsed by users using the terminal devices 601, 602, 603.
It should be noted that the method provided by the embodiment of the present invention is generally executed by the server 605, and accordingly, the apparatus is generally disposed in the server 605.
It should be understood that the number of terminal devices, networks, and servers in fig. 6 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 7, shown is a block diagram of a computer system 700 suitable for use with a terminal device implementing an embodiment of the present invention. The terminal device shown in fig. 7 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 7, the computer system 700 includes a Central Processing Unit (CPU)701, which can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)702 or a program loaded from a storage section 708 into a Random Access Memory (RAM) 703. In the RAM 703, various programs and data necessary for the operation of the system 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
The following components are connected to the I/O interface 705: an input portion 706 including a keyboard, a mouse, and the like; an output section 707 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 708 including a hard disk and the like; and a communication section 709 including a network interface card such as a LAN card, a modem, or the like. The communication section 709 performs communication processing via a network such as the internet. A drive 710 is also connected to the I/O interface 705 as needed. A removable medium 711 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 710 as necessary, so that a computer program read out therefrom is mounted into the storage section 708 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication section 709, and/or installed from the removable medium 711. The computer program performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 701.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor comprises a switching module and a loading module. Where the names of these modules do not in some cases constitute a limitation on the module itself, for example, a load module may also be described as "identifying a load module".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise:
receiving an identification obtaining request, and obtaining and feeding back an identification from a standby number section if the residual quantity of the current identification in the main number section is less than or equal to a first numerical value;
in the process of feeding back the identifier, if the residual amount of the identifier in the standby number segment is judged to be less than or equal to a second numerical value, the loading operation of the identifier in the main number segment is triggered, so that the identifier is extracted from a database and is stored in the main number segment.
According to the technical scheme of the embodiment of the invention, compared with the prior art, the method has the following beneficial effects:
1) setting a number segment as a cache library of the ID in the database, and when receiving an ID acquisition request, firstly processing the request by using the number segment so as to reduce the dependency on the database;
2) even if the database is abnormal, the main and standby number sections can provide ID acquisition service for a period of time, so that the high availability of the whole system is ensured, and precious time is strived for system recovery;
3) in the numerical range allowed by the database, the obtained ID is infinite, and the phenomenon of repeated recycling caused by the exhausted ID is not considered;
4) only when the residual quantity of the IDs in the number segments is small, the IDs are triggered to be extracted from the database, so that the connection quantity between the IDs and the database is greatly reduced, and the database is not easy to crash and crash even if high concurrency conditions occur;
5) fully considering the consumption rate of the ID in the number segment, and realizing the dynamic management of the ID in the number segment, wherein the ID quantity stored in the number segment corresponds to the consumption rate;
6) and performing strong consistency synchronization by adopting a main/standby mode. When the residual quantity of the ID in one number section is small, the other number section is triggered to load the ID, the number section is directly switched to the other number section for processing when no ID is available, the dependency on a database is reduced through the mode that the ID is loaded and used by the main number section and the standby number section in turn, and the high efficiency and the continuity of the ID acquisition are ensured.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (11)

1. An identity management method, comprising:
receiving an identification obtaining request, and obtaining and feeding back an identification from a standby number section if the residual quantity of the current identification in the main number section is less than or equal to a first numerical value;
in the process of feeding back the identifier, if the residual amount of the identifier in the standby number segment is judged to be less than or equal to a second numerical value, the loading operation of the identifier in the main number segment is triggered, so that the identifier is extracted from a database and is stored in the main number segment.
2. The method of claim 1, prior to said receiving an identity acquisition request, further comprising:
responding to the starting operation of the identification generation system, and acquiring a starting value of the identification in the current database; wherein the identification in the database is continuous and incremental;
determining the consumption of the mark within a preset time according to the consumption rate of the mark in the main number section, and taking the sum of the initial value and the consumption as an ending value of the mark;
and extracting the identifiers in the interval of the starting value and the ending value from the database and storing the identifiers in the main number segment.
3. The method of claim 2, further comprising, prior to said determining consumption of said token for a predetermined period of time based on said consumption rate identified in said prime segment:
and counting the first consumption identified in the primary number section within a preset historical time length, and taking the quotient of the first consumption and the preset historical time length as the consumption rate.
4. The method of claim 1, further comprising, before the obtaining the identifier from the spare number segment and feeding back the identifier if the remaining amount of the current identifier in the primary number segment is less than or equal to the first value:
if the residual amount of the mark in the main number section is less than or equal to a third numerical value, extracting the mark from the main number section, feeding back the mark, and triggering the loading operation of the mark in the standby number section; wherein the third value is greater than the first value.
5. The method of claim 2 or 4, wherein the triggering the load operation on the segment identified in the spare number comprises:
acquiring a first initial value of the current identifier of the database; wherein the first start value is located after and adjacent to the end value;
according to the consumption rate of the marks in the spare number segment, second consumption of the marks in a first preset time length is obtained, and then the sum of the first initial value and the second consumption is used as a first termination value of the marks;
and extracting identifications positioned in the first starting value interval and the first ending value interval from the database and storing the identifications into the spare number segment.
6. The method of claim 5, wherein the obtaining the identification from the spare number segment and the feedback comprises:
and according to the sequence from the first initial value to the first termination value, acquiring and feeding back the identifier of the current first sequence in the spare number segment, and then deleting the fed identifier.
7. The method of claim 1, further comprising, after said triggering a load operation on an identified in said primary number segment:
if the residual quantity of the identification in the standby number section is less than or equal to a fourth numerical value, switching to the main number section to process the identification acquisition request; wherein the second value is greater than the fourth value.
8. The method of claim 1, further comprising:
when the main number segment is monitored to be abnormal, switching to the standby number segment to process the identifier acquisition request; and
and when the standby number segment is monitored to be abnormal, switching to the main number segment to process the identifier acquisition request.
9. An identity management device, comprising:
the switching module is used for receiving the identifier acquisition request, and acquiring the identifier from the standby number section and feeding back the identifier if the residual quantity of the current identifier in the main number section is less than or equal to a first numerical value;
and the loading module is used for triggering the loading operation of the identifier in the main number segment if the residual quantity of the identifier in the standby number segment is judged to be less than or equal to a second numerical value in the identifier feedback process so as to extract the identifier from a database and store the identifier in the main number segment.
10. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-8.
11. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-8.
CN202010259314.9A 2020-04-03 2020-04-03 Identification management method and device Pending CN113495888A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010259314.9A CN113495888A (en) 2020-04-03 2020-04-03 Identification management method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010259314.9A CN113495888A (en) 2020-04-03 2020-04-03 Identification management method and device

Publications (1)

Publication Number Publication Date
CN113495888A true CN113495888A (en) 2021-10-12

Family

ID=77995060

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010259314.9A Pending CN113495888A (en) 2020-04-03 2020-04-03 Identification management method and device

Country Status (1)

Country Link
CN (1) CN113495888A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7966333B1 (en) * 2003-06-17 2011-06-21 AudienceScience Inc. User segment population techniques
CN105224637A (en) * 2015-09-24 2016-01-06 珠海许继芝电网自动化有限公司 A kind of based on PostgreSQL database active and standby/the comprehensive method of cluster application
US20160323098A1 (en) * 2015-04-28 2016-11-03 United States Government As Represented By The Secretary Of The Navy System and Method for High-Assurance Data Storage and Processing based on Homomorphic Encryption
CN108874946A (en) * 2018-06-05 2018-11-23 政采云有限公司 A kind of ID management method and device
CN109525658A (en) * 2018-11-09 2019-03-26 广州虎牙科技有限公司 A kind of production method, server, equipment, storage medium and operation system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7966333B1 (en) * 2003-06-17 2011-06-21 AudienceScience Inc. User segment population techniques
US20160323098A1 (en) * 2015-04-28 2016-11-03 United States Government As Represented By The Secretary Of The Navy System and Method for High-Assurance Data Storage and Processing based on Homomorphic Encryption
CN105224637A (en) * 2015-09-24 2016-01-06 珠海许继芝电网自动化有限公司 A kind of based on PostgreSQL database active and standby/the comprehensive method of cluster application
CN108874946A (en) * 2018-06-05 2018-11-23 政采云有限公司 A kind of ID management method and device
CN109525658A (en) * 2018-11-09 2019-03-26 广州虎牙科技有限公司 A kind of production method, server, equipment, storage medium and operation system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
王康;李东静;陈海光;: "分布式存储系统中改进的一致性哈希算法", 计算机技术与发展, no. 07, 22 June 2016 (2016-06-22) *

Similar Documents

Publication Publication Date Title
CN111061680A (en) Data retrieval method and device
CN112948498A (en) Method and device for generating global identification of distributed system
CN112671892A (en) Data transmission method, data transmission device, electronic equipment, medium and computer program product
CN113111626A (en) Sequence generation method and device, electronic equipment and storage medium
CN112395337A (en) Data export method and device
CN112948138A (en) Method and device for processing message
CN109144991B (en) Method and device for dynamic sub-metering, electronic equipment and computer-storable medium
CN113495888A (en) Identification management method and device
CN113127561B (en) Method and device for generating service single number, electronic equipment and storage medium
CN113760876A (en) Data filtering method and device
CN113742376A (en) Data synchronization method, first server and data synchronization system
CN111176679A (en) Application program updating method and device
CN109213815B (en) Method, device, server terminal and readable medium for controlling execution times
CN111538721A (en) Account processing method and device, electronic equipment and computer readable storage medium
CN113722193A (en) Method and device for detecting page abnormity
CN112130986A (en) Method for cleaning application memory, server and terminal
CN110875942B (en) Method and device for balancing load of hot spot program
CN112487001A (en) Method and device for processing request
CN113766437B (en) Short message sending method and device
CN111291038B (en) Data query method and device
CN115408630A (en) Page display method and device, electronic equipment and computer readable medium
CN112541025A (en) Service data interaction method and device
CN113760179A (en) Data processing method and device
CN113127504A (en) Business data display method and device
CN116187987A (en) Digital currency transaction 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