CN106911780B - Service ID generation method, device and system - Google Patents

Service ID generation method, device and system Download PDF

Info

Publication number
CN106911780B
CN106911780B CN201710112510.1A CN201710112510A CN106911780B CN 106911780 B CN106911780 B CN 106911780B CN 201710112510 A CN201710112510 A CN 201710112510A CN 106911780 B CN106911780 B CN 106911780B
Authority
CN
China
Prior art keywords
service
generation
number segment
target
server
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.)
Active
Application number
CN201710112510.1A
Other languages
Chinese (zh)
Other versions
CN106911780A (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 Sankuai Online Technology Co Ltd
Original Assignee
Beijing Sankuai Online 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 Sankuai Online Technology Co Ltd filed Critical Beijing Sankuai Online Technology Co Ltd
Priority to CN201710112510.1A priority Critical patent/CN106911780B/en
Publication of CN106911780A publication Critical patent/CN106911780A/en
Application granted granted Critical
Publication of CN106911780B publication Critical patent/CN106911780B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/51Discovery or management thereof, e.g. service location protocol [SLP] or web services

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention aims to provide a method, a device and a system for generating a service ID, wherein the method comprises the following steps: caching service identifications and ID number sections of a plurality of services, wherein the service identifications correspond to the ID number sections one by one; receiving an ID generation request, wherein the ID generation request carries a target service identifier; and if the cache is determined to have the target ID number section corresponding to the target service identification, determining the unique ID of the target service in the target ID number section. By the service ID generation method, the device and the system, the problems that the unique ID generation rate is low and the throughput of core services such as payment and finance is seriously influenced in the prior art can be solved.

Description

Service ID generation method, device and system
Technical Field
The invention relates to the technical field of internet, in particular to a method, a device and a system for generating a service ID.
Background
With the development of internet technology, when performing service processing on a background server, it is usually necessary to generate a unique ID (identity) to distinguish the same service operations of different users, for example, generating a unique ID as an order identifier to distinguish orders of each user, generating a unique ID as an article identifier to distinguish articles issued by each user, and generating a unique ID as a payment identifier to distinguish payment actions of each user.
The unique ID is characterized in that the unique IDs of different users are different from each other for the same service, such as a payment service, that is, the payment ID of each user is unique. The prior art provides a method for generating a unique ID, and specifically, a database is read and written by using the characteristics of a self-increment ID main key of the database, and a unique ID is obtained after each read and write operation.
However, the above method needs to read and write the database once each time the unique ID is generated, so the efficiency of generating the unique ID by the above method depends on the read-write performance of the database, and when the read-write performance of the database is poor, the generation rate of the unique ID is low, which seriously affects the throughput of core services such as payment and finance.
Disclosure of Invention
In view of this, the present invention provides a method, an apparatus, and a system for generating a service ID, so as to solve the problem in the prior art that the unique ID generation rate is low, and the throughput of core services such as payment and finance is seriously affected.
In a first aspect, an embodiment of the present invention provides a method for generating a service ID, where the method includes: caching service identifications and ID number sections of a plurality of services, wherein the service identifications correspond to the ID number sections one by one; receiving an ID generation request, wherein the ID generation request carries a target service identifier; and if the cache is determined to have the target ID number section corresponding to the target service identification, determining the unique ID of the target service in the target ID number section.
With reference to the first aspect, an embodiment of the present invention provides a first possible implementation manner of the first aspect, where caching service identifiers and multiple ID number segments of multiple services includes: reading and caching service identifications of a plurality of services stored in a database server; reading the number segment parameters of the plurality of services stored in the database server; and determining the ID number segment of each service according to the number segment parameters, and caching the ID number segment of each service.
With reference to the first aspect, an embodiment of the present invention provides a second possible implementation manner of the first aspect, where the method further includes: if the cache is determined to have no target ID number segment corresponding to the target service identifier, a number segment setting instruction is sent to a database server; acquiring a target service identifier determined by the database server according to the number segment setting instruction and a target ID number segment corresponding to the target service identifier; and caching the target service identification and the corresponding target ID number segment thereof, and determining the unique ID of the target service in the target ID number segment.
With reference to the first aspect or the second possible implementation manner of the first aspect, an embodiment of the present invention provides a third possible implementation manner of the first aspect, where the determining a unique ID of a target service in the target ID number segment includes: determining a starting value and an ending value of the target ID number segment; and taking the value which is greater than the preset difference value of the starting value and less than or equal to the ending value as the unique ID.
With reference to the third possible implementation manner of the first aspect, an embodiment of the present invention provides a fourth possible implementation manner of the first aspect, where the method further includes: updating the start value of the target ID number segment with the unique ID.
With reference to the first aspect, an embodiment of the present invention provides a fifth possible implementation manner of the first aspect, where the method further includes: if the ID number segment is determined not to meet the preset requirement, searching a number segment parameter corresponding to the ID number segment in a database server, and updating the ID number segment according to the number segment parameter; and caching the updated ID number segment.
With reference to the fifth possible implementation manner of the first aspect, an embodiment of the present invention provides a sixth possible implementation manner of the first aspect, where the method further includes: determining a start value and an end value of the ID number segment; and if the initial value is equal to or larger than the termination value, determining that the ID number segment does not meet the preset requirement.
With reference to the fifth possible implementation manner of the first aspect, an embodiment of the present invention provides the seventh possible implementation manner of the first aspect, where the number segment parameter includes a termination value of the ID number segment generated in the previous time of the service to which the number segment belongs and a set span of the ID number segment of the service to which the number segment belongs; the updating the ID number segment according to the number segment parameter comprises: acquiring a termination value of the ID number segment generated in the previous time of the business as an initial value of the updated ID number segment; and acquiring the sum of the termination value of the ID number segment generated in the previous time of the service and the set span as the updated termination value of the ID number segment.
With reference to the seventh possible implementation manner of the first aspect, an embodiment of the present invention provides an eighth possible implementation manner of the first aspect, where the method further includes: detecting the frequency of updating the ID number section according to the number section parameter; and if the frequency is higher than a preset frequency threshold value, increasing the value of the set span in the number section parameter.
In a second aspect, an embodiment of the present invention provides a method for generating a service ID, where the method includes: a load balancing server acquires an ID generation request, determines a target ID generation server for processing the ID generation request from a plurality of ID generation servers, and sends the ID generation request to the target ID generation server; the ID generation requests carry target service identifications, each ID generation server caches service identifications and ID number segments of a plurality of services, the service identifications correspond to the ID number segments one by one, and the ID number segments corresponding to the same service identification cached in all the ID generation servers are different; and after receiving the ID generation request, the target ID generation server determines the unique ID of the target service in the target ID number segment if the target ID number segment corresponding to the target service identification is determined to be cached.
In a third aspect, an embodiment of the present invention provides a service ID generation system, including a load balancing server and multiple ID generation servers; each ID generation server caches service identifications and ID number segments of a plurality of services, wherein the service identifications correspond to the ID number segments one by one, and the ID number segments corresponding to the same service identification cached in all the ID generation servers are different; the load balancing server is used for determining a target ID generation server for processing an ID generation request in all the ID generation servers and sending the ID generation request to the target ID generation server, wherein the ID generation request carries a target service identifier; and the target ID generation server is used for determining the unique ID of the target service in the target ID number segment if the target ID number segment corresponding to the target service identification is determined to be cached after the ID generation request is received.
With reference to the third aspect, an embodiment of the present invention provides a first possible implementation manner of the third aspect, where the load balancing server is specifically configured to determine, according to a load balancing algorithm, the target ID generation server that processes the ID generation request among all the ID generation servers.
In a fourth aspect, an embodiment of the present invention provides a service ID generation apparatus, including: the cache module is used for caching service identifications and ID number sections of a plurality of services, wherein the service identifications correspond to the ID number sections one by one; the receiving module is used for receiving an ID generation request, and the ID generation request carries a target service identifier; and the determining module is used for determining the unique ID of the target service in the target ID number segment if the target ID number segment corresponding to the target service identification is determined in the cache.
In a fifth aspect, an embodiment of the present invention provides a computer device, including a memory and a processor, where the memory stores a computer program executable on the processor, and the processor executes the computer program to perform the method according to the first aspect.
In a sixth aspect, an embodiment of the present invention provides a computer storage medium, where a computer program is stored on the computer storage medium, and the computer program, when executed by a processor, performs the method according to the first aspect.
In the embodiment of the invention, the service identifications of a plurality of services and the ID number sections of the services are cached in advance, and after the ID generation request is received, if the target ID number section corresponding to the target service identification is cached, the unique ID of the target service is determined in the target ID number section. By the service ID generation method, the device and the system in the embodiment of the invention, the unique ID can be determined based on the cached ID number segment, and the database does not need to be read and written, so that the generation efficiency of the unique ID can be improved, and the problems that the throughput of core services such as payment and finance is seriously influenced due to low generation rate of the unique ID in the prior art are solved.
In order to make the aforementioned and other objects, features and advantages of the present invention comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained according to the drawings without inventive efforts.
Fig. 1 is a first flowchart of a method for generating a service ID according to an embodiment of the present invention;
fig. 2 is a schematic application environment diagram of a service ID generation method according to an embodiment of the present invention;
fig. 3 is a second flowchart of a service ID generation method according to an embodiment of the present invention;
fig. 4 is a schematic composition diagram of a service ID generation system according to an embodiment of the present invention;
fig. 5 is a third flowchart illustrating a method for generating a service ID according to an embodiment of the present invention;
fig. 6 is a schematic diagram illustrating a module composition of a service ID generation apparatus according to an embodiment of the present invention;
fig. 7 is a schematic diagram illustrating a module composition of a computer device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present invention without making any creative effort, shall fall within the protection scope of the present invention.
Considering that when the method in the prior art is used to generate the unique ID, the generation efficiency depends on the read-write performance of the database, and when the read-write performance of the database is poor, the generation rate of the unique ID is low, which seriously affects the throughput of core services such as payment and finance, the invention provides a method, a device and a system for generating a service ID, which are specifically described below by embodiments.
Fig. 1 is a first flowchart of a service ID generation method according to an embodiment of the present invention, where the method is executed by an ID generation server, and in particular, executed by a Remote Procedure Call (RPC) service capable of load balancing in the ID generation server, as shown in fig. 1, the method includes the following steps:
step S102, caching service identifications and ID number sections of a plurality of services, wherein the service identifications correspond to the ID number sections one by one.
In this embodiment, a plurality of services are first determined, where the services are services that need to generate a unique ID, and include an ordering service, a payment service, a comment posting service, an article posting service, and the like. After a plurality of services are determined, an ID number segment is allocated to each service, the ID number segment refers to a pure number interval including a plurality of ID values, the pure number interval can be represented by a start value and an end value, such as the ID number segments of the following single services are 1 to 100, wherein the ID number segment includes 100 ID values, the minimum ID value is 1, namely the start value, and the maximum ID value is 100, namely the end value. The role of allocating the ID number segment to each service is to select a value from the ID number segment corresponding to a certain service as the unique ID of the service when the unique ID of the service needs to be generated.
The unique ID has service uniqueness, and for the same service, the unique ID of the service generated each time is different, for example, the order identifier generated each time is different, so as to distinguish the order placing actions of different users, but for different services, the unique ID of different services may be the same, for example, the generated order identifier and the generated article identifier may be the same. Therefore, in this embodiment, when ID number segments are allocated to different services, the ID number segments of different services may be the same, and the ID number segment of the following single service and the ID number segment of the payment service are both 100 to 200.
In a specific implementation manner, a number table is established in the database server for each service, and the number table is stored in a disk of the database server, and table 1 is an example of the number table provided in the embodiment of the present invention, and an ID number segment of each service is generated through the number table.
TABLE 1
Field(s) Means of
biz_tag Service identification
max_id Termination value of ID number segment generated before business
step Set span of ID number segment of service
desc Remark information of affiliated service
update_time Latest update time of the issue table
In table 1, the biz _ tag field is a service identifier of each service, and is used to distinguish each service that needs to generate a unique ID; the max _ ID field corresponds to the biz _ tag field and represents the terminal value of the ID number segment generated by the previous time of the service, namely the maximum value of the ID number segment generated by the previous time of the service, and the maximum value of the max _ ID field can be 2^64, namely 9223372036854775807; the step field corresponds to the biz _ tag field and represents the set span of the ID number field of the service, namely the difference between the initial value and the terminal value of the ID number field of the service, and the maximum value of the step field can be 2^32, namely 2147483647; desc corresponds to the biz _ tag field and represents remark information of the service, and the remark information may be a peak value of the number of requests per second (QPS) of the service, and a service line where the service is located, for example, the remark information is a take-out order core service, a QPS peak value 2000, and a QPS average value 800; the update _ time corresponds to the biz _ tag field and indicates the latest update time of the number table, wherein the action of updating the number table may be to modify the max _ id field. In table 1, the termination value of the ID number segment generated in the previous time of the service and the set span of the ID number segment of the service are collectively referred to as a number segment parameter.
After a number list is established for each service in a database server, the service identification of each service and the ID number section of each service are determined according to the content of the number list corresponding to each service. Specifically, a service identifier of each service stored in the database server, that is, the aforementioned biz _ tag field, is read, the service identifier of each service is determined, a number segment parameter of each service stored in the database server is read, and an ID number segment of each service is determined according to the number segment parameter of each service, where the number segment parameter includes a termination value of an ID number segment generated before the service to which the service belongs, that is, a value of a max _ ID field, and a set span of the ID number segment of the service to which the service belongs, that is, a value of a step field.
The specific process of determining the ID number segment of each service according to the ending value of the ID number segment generated last time of each service and the set span of the ID number segment of each service is to determine the ending value of the ID number segment generated last time as the starting value of the ID number segment generated currently, determine the sum of the ending value of the ID number segment generated last time and the set span as the ending value of the ID number segment generated currently, and determine the ID number segment of each service according to the determined starting value and the ending value, wherein the ending value of the ID number segment generated last time of each service is initially 0, the set span is greater than 0, and the ID number segment can be represented as a closed interval or an open interval from the starting value to the ending value. It can be seen that the ID number segment in this embodiment is a pure number segment including a plurality of ID values.
It can be understood that, for the above-mentioned number table, since the max _ ID field represents the termination value of the ID number segment generated before the service to which the terminal belongs, after the ID number segment of the service is determined, the value of max _ ID needs to be modified correspondingly, so that the value of max _ ID always represents the termination value of the ID number segment generated before the service to which the terminal belongs. The termination value of the ID number segment generated by each service in the previous time is initially 0, and after the ID number segment is generated once, the termination value of the ID number segment generated by each service in the previous time is larger than zero and is equal to the value of the set span.
And after determining the service identification of each service and the ID number section of each service, caching the service identification of each service and the ID number section of each service, wherein the service identifications correspond to the ID number sections one by one.
Step S104, an ID generation request is received, and the ID generation request carries a target service identifier.
In this embodiment, the service server sends an ID generation request to the ID generation server, where the ID generation request carries a target service identifier, the ID generation server generates a unique ID of the target service according to the ID generation request, and after the ID generation server generates the unique ID, the generated unique ID is returned to the service server, and the service server performs service processing using the generated unique ID, such as order processing using the generated unique ID as an order identifier.
In this embodiment, the ID generation server is configured to receive an ID generation request sent by the service server and generate a unique ID, and since there are many services processed and the number of unique IDs is large, the ID generation server does not need to store the generated unique ID, and only needs to return the unique ID to the service server, and the service server processes the received unique ID according to the service requirement.
Fig. 2 is a schematic application environment diagram of a service ID generation method according to an embodiment of the present invention, where the method in this embodiment is applied to an application environment shown in fig. 2, a service server 100 is configured to send an ID generation request to an ID generation server 200, a plurality of ID generation servers 200 are configured to generate a unique ID after receiving the ID generation request, a database server 300 is the aforementioned database server, the aforementioned number table is disposed in a disk of the database server 300, and each ID generation server 200 is configured to obtain a service identifier of each service and an ID number segment of each service from the database server 300 and cache the service identifier and the ID number segment.
In fig. 2, a plurality of ID generation servers are provided, and the application environment in fig. 2 generates a unique ID, so that when a certain ID generation server fails, another ID generation server can generate a unique ID, thereby improving the usability of the system.
In the application system shown in fig. 2, a load balancer is provided in the service server 100, and after the service server 100 generates an ID generation request, the ID generation server 200 that processes the ID generation request is selected by a load balancing algorithm in the load balancer, and the ID generation request is transmitted to the specified ID generation server 200.
In a specific embodiment, the service server 100 preferably determines the ID generation server 200 that processes the ID generation request among the plurality of ID generation servers 200 by using a smooth weighted round robin algorithm. The principle of the smoothed weighted polling algorithm is: the selected weight of each server is preset according to the load condition of each server, each time a server is selected, the server with the highest weight is selected, the weight of the selected server is updated by the sum of the weights of all the servers, the current weight of each server is updated by the preset weight of each server, the weight of each server after current selection is obtained after updating, and next selection is sequentially carried out.
For example, assume that the weights of three servers a, B, and C are 4,2, and 1, respectively. According to this configuration, in 7 requests, a is chosen 4 times, B is chosen 2 times, and C is chosen 1 time, and the distribution is smooth, and table 2 shows the weight change of A, B, C three servers after each selection.
TABLE 2
Request sequence number A. B, C Current weight Selected server Once update weight Secondary update weight
1 (4,2,1) A (-3,2,1) (1,4,2)
2 (1,4,2) B (1,-3,2) (5,-1,3)
3 (5,-1,3) A (-2,-1,3) (2,1,4)
4 (2,1,4) C (2,1,-3) (6,3,-2)
5 (6,3,-2) A (-1,3,-2) (3,5,-1)
6 (3,5,-1) B (3,-2,-1) (7,0,0)
7 (7,0,0) A (0,0,0) (4,2,1)
In table 2, it is first determined A, B, C that the initial weights of the three servers are 4,2, and 1, when selecting for the first time, the server a with the highest weight is selected, then the weight of a is updated by using the sum of the weights of all the servers and 7, specifically, the weight of a is subtracted from 7 to obtain the updated weight of A, B, C, that is, -3, 2, and 1, then the current weight of each server is updated by using the preset weight of each server, specifically, the current weight of each server is added to the corresponding preset weight to obtain the weight of each server after selecting for the current time, that is, 1, 4, and 2, and then the next selection is performed in sequence.
As shown in table 2, after 7 selections, the weight of each server becomes the initial weight, so that the next polling is started. In the smooth weighted polling algorithm, the initial weight of each server can be preset according to the load condition of each server, and the selected times of each server can be ensured through the smooth weighted polling algorithm, so that the selected times of each server are adaptive to the respective load.
After receiving the ID generation request sent by the service server 100, the ID generation server 200 obtains the target service identifier carried in the ID generation request, and executes step S106.
And step S106, if the cache is determined to have the target ID number section corresponding to the target service identification, determining the unique ID of the target service in the target ID number section.
And the ID generation server searches in the cache according to the target service identification carried by the ID generation request, judges whether a target ID number section corresponding to the target service identification is cached, and determines the unique ID of the target service in the target ID number section if the target ID number section is cached. The target service, the target service identifier and the target ID number segment correspond to each other.
In this embodiment, if it is determined that there is no target ID number segment corresponding to the target service identifier in the cache, a number segment setting instruction is sent to the database server, then the target service identifier determined by the database server according to the number segment setting instruction and the target ID number segment corresponding to the target service identifier are obtained, finally, the target service identifier and the target ID number segment corresponding to the target service identifier are cached, and the unique ID of the target service is determined in the target ID number segment.
Specifically, if it is determined that there is no target ID number segment corresponding to the target service identifier in the cache, it indicates that there is no number segment parameter corresponding to the target service identifier and the target service identifier stored in the database server, that is, there is no number transmission table of the target service, and therefore in this embodiment, a number segment setting instruction is sent to the database server, where the number segment setting instruction carries the target service identifier and the number segment parameter corresponding to the target service identifier, and the number transmission table setting parameter is also included, so that the database server sets up the number transmission table of the target service according to the number segment setting instruction, and stores the target service identifier and the number segment parameter corresponding to the target service identifier in the number transmission table of the target service. The number segment parameter corresponding to the target service identifier includes a termination value of an ID number segment generated before the target service and a set span of the ID number segment of the target service, the termination value of the ID number segment generated before the target service is initially set to 0, and the set span is greater than 0.
After the database server stores the target service identification and the number segment parameter corresponding to the target service identification, the ID generation server obtains the target service identification and the target ID number segment determined by the database server according to the number segment setting instruction. Specifically, in the database server, the target ID number segment is stored in the form of a number segment parameter, and the termination value of the ID number segment generated before the target service in the number segment parameter is the start value of the ID number segment currently generated by the target service, and the set span of the ID number segment of the target service in the number segment parameter is the difference between the start value and the termination value of the ID number segment currently generated by the target service.
After the ID generation server obtains the target service mark and the corresponding target ID number segment thereof, the ID generation server caches the target service mark and the corresponding target ID number segment thereof, and determines the unique ID of the target service in the target ID number segment. Because the target service identification and the target ID number segment are cached, the unique ID of the target service can be generated when the target service identification is received again.
In this embodiment, the specific determination of the unique ID of the target service in the target ID number segment is as follows: and determining a starting value and an ending value of the target ID number segment, and taking a value which is greater than the starting value by a preset difference value and less than or equal to the ending value as a unique ID. For example, if the start value and the end value of the target ID number segment are set to 1 and 100, respectively, a value greater than 1 by a preset difference value and less than or equal to 100 is used as the unique ID, where the preset difference value is greater than or equal to 1.
In view of the fact that the unique ID determined each time needs to be different for the same service, in order to determine the unique ID conveniently, in this embodiment, a preset difference value is set to be 1, and after the unique ID is determined each time, the start value of the target ID number segment is updated by using the unique ID, so that in the target ID number segment, the value between the start value and the end value is determined one by one as the unique ID starting from the start value, wherein the unique ID does not include the start value but includes the end value because the unique ID is greater than the preset difference value of the start value and is less than or equal to the end value.
In the above example, the unique ID generated this time is 2, and the start value of the update target ID number segment is 2, and when the unique ID is determined next time, the unique ID is determined to be 3, and the start value of the update target ID number segment is 3, and so on.
In the embodiment of the invention, the service identifications of a plurality of services and the ID number sections of the services are cached in advance, and after the ID generation request is received, if the target ID number section corresponding to the target service identification is cached, the unique ID of the target service is determined in the target ID number section. By the service ID generation method in the embodiment of the invention, the unique ID can be determined based on the cached ID number segment, and the database does not need to be read and written, so that the generation efficiency of the unique ID can be improved, and the problem that the throughput of core services such as payment and finance is seriously influenced due to low generation rate of the unique ID in the prior art is solved.
According to the above process of determining the unique ID of the target service in the target ID number segment, since the start value of the target ID number segment is updated after the unique ID is determined each time, when a plurality of unique IDs are determined, the start value and the end value of the target ID number segment will be equal, and the unique ID cannot be determined in the target ID number segment, in this embodiment, in order to find and process such a situation, it is further detected whether the cached ID number segment meets the preset requirement, specifically: and the ID generation server determines the initial value and the termination value of the ID number segment, if the initial value is less than the termination value, the corresponding ID number segment is determined to meet the preset requirement, and if the initial value is equal to or greater than the termination value, the corresponding ID number segment is determined not to meet the preset requirement.
In this embodiment, whether each cached ID number segment meets the preset requirement may be periodically detected, for example, the detection is performed once every 1 hour, and after the target service identifier is received and the target ID number segment corresponding to the target service identifier is found, whether the target ID number segment meets the preset requirement may be detected. The regular detection mode can not affect the obtaining efficiency of the unique ID of the target service, however, the detection amount is large, each ID number section needs to be detected, the detection amount of the mode for detecting the target ID number section is small, the detection is only carried out on the target ID number section, and once the detection finds that the target ID number section does not meet the preset requirement, the target ID number section needs to be updated, and the determining efficiency of the unique ID of the target service is affected. In practical process, one of the two detection modes or the ID number section can be selected according to the advantages and disadvantages of the two detection modes.
If the ID number section does not meet the preset requirement, the number section parameter corresponding to the ID number section is searched in the database server, and the ID number section is updated according to the number section parameter. As can be seen from the foregoing, the segment parameter includes the termination value of the ID segment generated before the service to which the segment belongs and the set span of the ID segment of the service to which the segment belongs, and therefore, updating the ID segment according to the segment parameter may be: and acquiring the ending value of the ID number segment generated last time by the business as the initial value of the updated ID number segment, and acquiring the sum of the ending value of the ID number segment generated last time by the business and the set span as the ending value of the updated ID number segment.
And after the ID number section is updated, replacing the ID number section before updating with the updated ID number section, and caching the updated ID number section.
It should be noted that, for the number segment parameter in the database server, especially the termination value of the ID number segment generated before the service, after the ID number segment corresponding to the service is updated each time, the termination value, that is, the value of max _ ID, needs to be modified, so that the termination value always represents the termination value of the ID number segment generated before the service.
Through the ID number segment updating method in this embodiment, the ID number segment generated by each service each time is connected to the ID number segment generated last time, for example, if the termination value of the ID number segment generated last time of a certain service is 100, and the set span is 50, the ID number segment generated last time of the service is 50 to 100, and the ID number segment generated currently of the service is 100 to 150, thereby ensuring the sequentiality between the ID number segments and improving the availability of the method in this embodiment.
Corresponding to the distributed system in fig. 2, in the manner in this embodiment, the number segment parameters are uniformly recorded in the database server, and the functions of the ID generation servers are the same. When one ID generation server a acquires an ID number segment from the database server 300, the database server 300 can update the number segment parameter, record the end value of the ID number segment generated this time, and when another ID generation server B acquires an ID number segment of the same service from the database server 300, determine the ID number segment acquired this time according to the end value of the ID number segment generated last time of the service and the set span of the ID number segment, and the ID number segment acquired this time is not repeated with the ID number segment acquired by the ID generation server a, thereby ensuring that each ID generation server 200 can acquire different ID number segments for the same service, and ensuring that the unique IDs generated by different ID generation servers 200 for the same service each time are different.
In this embodiment, when the cached ID number segment of a certain service does not meet the preset requirement, the ID number segment of the service is updated according to the number segment parameter stored in the database server, so that the ID generation server can continue to generate the unique ID of the service. Considering that the number of unique IDs generated in the near future is too large when the number update frequency is too fast, it is preferable to increase the value of the span set in the number parameter in order to reduce the read/write frequency of the database server. For example, the frequency of updating the ID number segment according to the number segment parameter is detected, and if the frequency is higher than a preset frequency threshold, the value of the set span in the number segment parameter is increased, so that the span of the ID number segment generated each time is increased, and the number of times of reading and writing the disk of the database server is reduced.
Fig. 3 is a second flowchart of the method for generating a service ID according to the embodiment of the present invention, and as shown in fig. 3, the method includes:
step 301, setting a number list. Setting a number sending table for a plurality of services in a database server, wherein the number sending table is stored in a magnetic disk, each service corresponds to one number sending table, each number sending table comprises a service identifier and a number section parameter, and the number section parameter comprises a termination value of an ID number section generated by the service which the number sending table belongs to at the previous time and a set span of the ID number section of the service which the number sending table belongs to;
step S302, caching the ID number segment. Determining an ID number section of each service according to the number section parameter of each service, and caching a service identifier of each service and the ID number section of each service, wherein the service identifiers correspond to the ID number sections one to one;
step S303, a request is received. Receiving an ID generation request sent by a service server, wherein the ID generation request carries a target service identifier;
step S304, judging whether the target ID number segment is cached or not. Checking whether a target ID number segment corresponding to the target service identifier is cached, if so, executing a step S305, otherwise, executing a step S310;
step S305, judging whether the preset requirement is met. Judging whether the target ID number section meets the preset requirement, if so, executing a step S306, otherwise, executing a step S307;
in step S306, the unique ID is determined. Determining a unique ID in the target ID number segment;
step S307, number segment parameters are searched. Searching a number segment parameter corresponding to the target service identifier in a database server;
step S308, the target ID number segment is updated. Updating the target ID number section according to the searched number section parameter;
step S309, buffer the target ID number segment and determine the unique ID. Caching the updated target ID number segment, and determining a unique ID in the updated target ID number segment;
step S310, setting a target ID number segment. Setting a number list for a target service identifier in a database server, and determining a target ID number segment corresponding to the target service identifier according to number segment parameters in the number list;
step S311, buffer the target ID number segment and determine the unique ID. Caching a target service identifier and a target ID number segment corresponding to the target service identifier, and determining a unique ID in the target ID number segment;
step S12, the unique ID is returned. And returning the determined unique ID to the service server.
Compared with the prior art, the unique ID generated by the method in the embodiment is in a pure digital form, which is more beneficial to storage and search, in addition, the form of storing the number segment parameters of each service in the database server is utilized, so that the unique ID generated by all the ID generation servers can be ensured to be based on the number segment parameters stored in the database server, the unified management of the unique ID is convenient, in addition, in the embodiment, the database server is read and written only under the condition that the ID number segments are used up or the ID number segments are not cached, the read-write times of a disk of the database server are reduced, and the generation performance of the unique ID is improved.
Further, the set span of the ID number segment in this embodiment can be determined arbitrarily, and when the set span is large, the number of times of reading and writing of the disk of the database server can be reduced.
Further, in this embodiment, the number segment parameter is set in the database server, the unique ID is generated according to the cache content of the ID generation server, based on the principle that data in the database server is not lost when power fails and data in the cache is lost when a certain ID generation server is restarted due to a fault, because the ID number segment of each service in the ID generation server is lost, the ID generation server needs to obtain the next ID number segment of each service from the database server, and this processing manner can ensure that the unique ID generated after the ID generation server is restarted is not repeated with the unique ID generated before, and ensure the uniqueness of the unique ID.
Corresponding to the service ID generation method described above, an embodiment of the present invention further provides a service ID generation system, fig. 4 is a schematic diagram illustrating a composition of the service ID generation system provided in the embodiment of the present invention, as shown in fig. 4, the system includes a load balancing server 400 and a plurality of ID generation servers 200, and the ID generation server 200 is the ID generation server 200 shown in fig. 2.
Each ID generation server 200 caches a plurality of service identifiers and a plurality of ID number segments, wherein the service identifiers correspond to the ID number segments one to one, and the ID number segments corresponding to the same service identifier cached in all the ID generation servers 200 are different.
For example, the ID generation server a and the ID generation server B both cache an order service identifier and an ID number segment corresponding to the order service identifier, and a payment service identifier and an ID number segment corresponding to the payment service identifier, and the ID number segment corresponding to the order service identifier cached by the ID generation server a is different from the ID number segment corresponding to the order service identifier cached by the ID generation server B, and the ID number segment corresponding to the payment service identifier cached by the ID generation server a is different from the ID number segment corresponding to the payment service identifier cached by the ID generation server B.
In a specific embodiment, referring to the application environment shown in fig. 2, the ID generation server a determines, according to the number segment parameter corresponding to the order service identifier stored in the database server 300, that the ID number segment corresponding to the order service identifier is 100 to 200, and synchronously modifies the end value of the ID number segment generated last time by the order service stored in the database server 300 to be 200, the ID generation server B obtains the ID number segment of the order service after the ID generation server a, and the ID generation server B determines, according to the number segment parameter corresponding to the order service identifier stored in the database server 300, that the ID number segment corresponding to the order service identifier is 300 to 400. It can be seen that when each ID generation server 200 acquires an ID number segment from the database server 300, because only one ID generation server 200 can acquire an ID number segment at the same time, and the database server 300 stores the end value of the ID number segment generated by each service at the previous time, the ID number segments corresponding to the same service identifier acquired by each ID generation server 200 are different, and the ID number segments corresponding to the same service identifier acquired before and after are linked together, so the ID number segments corresponding to the same service identifier cached in each ID generation server 200 are different.
By making the ID number segments corresponding to the same service identifier cached in each ID generation server 200 different, the unique ID generated by each ID generation server 200 for the same service can be made different, so that the unique ID of the same service generated by each ID generation server 200 has uniqueness.
In fig. 4, the load balancing server 400 is configured to determine, among all the ID generation servers 200, a target ID generation server that processes an ID generation request, and send the ID generation request to the target ID generation server, where the ID generation request carries a target service identifier. Specifically, the load balancing server 400 determines a target ID generation server that processes the ID generation request among all the ID generation servers 200 according to a load balancing algorithm, and it can be understood that the target ID generation server is one of all the ID generation servers 200.
In one embodiment, the load balancing server 400 is identical to the traffic server 100 in fig. 2, and the load balancing server 400 generates an ID generation request and determines a target ID generation server to process the ID generation request. In another embodiment, the load balancing server 400 is provided separately from the service server 100, and the load balancing server 400 receives the ID generation request sent by the service server 100 and determines the target ID generation server to process the ID generation request.
The load balancing server 400 determines the target ID generation server in all the ID generation servers 200 according to the load balancing algorithm, and the specific process is the same as the content of the foregoing method, and is not described herein again.
In fig. 4, the target ID generation server is configured to, after receiving the ID generation request, determine the unique ID of the target service in the target ID number segment if it is determined that the target ID number segment corresponding to the target service identifier is cached.
The target ID generation server in fig. 4 is an execution subject of the service ID generation method, and the specific process of determining the unique ID of the target service by the target ID generation server may refer to the content of the method, which is not described herein again.
Through the service ID generation system in fig. 4, the unique ID can be determined based on the cached ID number segment, and a database does not need to be read and written, so that the generation efficiency of the unique ID can be improved, and the problem that the throughput of core services such as payment and finance is seriously affected due to low generation rate of the unique ID in the prior art is solved.
Corresponding to the system shown in fig. 4, an embodiment of the present invention further provides a method for generating a service ID, fig. 5 is a third schematic flow chart of the method for generating a service ID provided in the embodiment of the present invention, and as shown in fig. 5, the method includes:
in step S202, the load balancing server acquires the ID generation request, determines a target ID generation server that processes the ID generation request among the plurality of ID generation servers, and transmits the ID generation request to the target ID generation server.
The ID generation request carries target service identification, each ID generation server caches service identification and ID number segments of a plurality of services, the service identification and the ID number segments are in one-to-one correspondence, and the ID number segments cached in all the ID generation servers and corresponding to the same service identification are different.
In one embodiment, the load balancer receives an ID generation request sent by a service server, and in another embodiment, the load balancer generates an ID generation request. The load balancer determines a target ID generation server that processes the ID generation request among the plurality of ID generation servers according to a load balancing algorithm, and transmits the ID generation request to the target ID generation server.
Step S204, after the target ID generation server receives the ID generation request, if the target ID number segment corresponding to the target service identification is determined to be cached, the unique ID of the target service is determined in the target ID number segment.
And the target ID generation server receives the ID generation request sent by the load balancing server, searches whether a target ID number section corresponding to the target service identification exists in the cache, and determines the unique ID of the target service in the target ID number section if the target ID number section exists.
Since the method in fig. 5 is performed based on the system in fig. 4, the description of the system shown in fig. 4 may be referred to for parts of the method, and will not be repeated here.
Through the service ID generation method in fig. 5, the unique ID can be determined based on the cached ID number segment, and a database does not need to be read and written, so that the generation efficiency of the unique ID can be improved, and the problem that the throughput of core services such as payment and finance is seriously affected due to low generation rate of the unique ID in the prior art is solved.
Corresponding to the above-mentioned service ID generation method, an embodiment of the present invention further provides a service ID generation apparatus, fig. 6 is a schematic diagram of module composition of the service ID generation apparatus provided in the embodiment of the present invention, and as shown in fig. 6, the apparatus includes:
a cache module 41, configured to cache service identifiers and multiple ID number segments of multiple services, where the service identifiers and the ID number segments correspond to each other one to one;
a receiving module 42, configured to receive an ID generation request, where the ID generation request carries a target service identifier;
the determining module 43 is configured to determine the unique ID of the target service in the target ID number segment if it is determined that the cache has the target ID number segment corresponding to the target service identifier.
Wherein, the buffer module 41 includes: the first cache unit is used for reading and caching the service identifiers of the plurality of services stored in the database server; the reading unit is used for reading the number segment parameters of a plurality of services stored in the database server; and the second cache unit is used for determining the ID number section of each service according to the number section parameters and caching the ID number section of each service.
Wherein the determining module 43 comprises: the first determining unit is used for determining the starting value and the ending value of the target ID number segment, and the second determining unit is used for taking the value which is larger than the starting value by a preset difference value and is smaller than or equal to the ending value as the unique ID.
Considering that the initial value in the ID number field needs to be updated with the generation of the unique ID, the apparatus in this embodiment further includes: and the initial value updating module is used for updating the initial value of the target ID number segment by using the unique ID after the second determining unit determines the unique ID.
In view of the fact that there is no target ID number segment corresponding to the target service identifier in the cache, the apparatus in this embodiment further includes: the instruction sending module is used for sending a number segment setting instruction to the database server if the cache is determined to have no target ID number segment corresponding to the target service identifier; the number segment determining module is used for acquiring a target service identifier determined by the database server according to the number segment setting instruction and a target ID number segment corresponding to the target service identifier; and the ID determining module is used for caching the target service identification and the corresponding target ID number segment thereof and determining the unique ID of the target service in the target ID number segment.
In consideration of the case where each value in the ID number segment is determined to be a unique ID, the apparatus in the present embodiment further includes: the number segment updating module is used for searching the number segment parameter corresponding to the ID number segment in the database server and updating the ID number segment according to the number segment parameter if the ID number segment is determined not to meet the preset requirement; and the cache updating module is used for caching the updated ID number section.
Corresponding to the above number segment updating module, the apparatus in this embodiment further includes: the detection parameter determining module is used for determining the starting value and the ending value of the ID number segment; and the detection result determining module is used for determining that the ID number section does not meet the preset requirement if the initial value is equal to or greater than the termination value.
The number segment parameters comprise the termination value of the ID number segment generated in the last time of the service and the set span of the ID number segment of the service; wherein, number section updates the module and includes: the first updating unit is used for acquiring a termination value of an ID number segment generated in the previous time of the business to which the business belongs as an initial value of the ID number segment after updating; and the second updating unit is used for acquiring the sum of the termination value of the ID number segment generated in the previous time of the service to which the terminal device belongs and the set span as the termination value of the ID number segment after updating.
In consideration of the frequent update of number segments, the apparatus in this embodiment further includes: the frequency detection module is used for detecting the frequency of updating the ID number section according to the number section parameter; and the span increasing module is used for increasing the value of the set span in the number section parameter if the detected frequency is higher than a preset frequency threshold value.
In the embodiment of the invention, the service identifications of a plurality of services and the ID number sections of the services are cached in advance, and after the ID generation request is received, if the target ID number section corresponding to the target service identification is cached, the unique ID of the target service is determined in the target ID number section. By the service ID generation device in the embodiment of the invention, the unique ID can be determined based on the cached ID number segment, and the database does not need to be read and written, so that the generation efficiency of the unique ID can be improved, and the problem that the throughput of core services such as payment and finance is seriously influenced due to low generation rate of the unique ID in the prior art is solved.
Corresponding to the service ID generation method, an embodiment of the present invention further provides a computer device, fig. 7 is a schematic diagram illustrating a module composition of the computer device according to the embodiment of the present invention, as shown in fig. 7, including a memory 1000 and a processor 2000, where the memory 1000 stores a computer program that can be run on the processor 2000, and the processor 2000 executes the service ID generation method according to the embodiment when running the computer program.
Specifically, the memory 1000 and the processor 2000 can be general memories and processors, which are not specifically limited herein, the memory 1000 and the processor 2000 are connected through a communication bus, and when the processor 2000 runs a computer program stored in the memory 1000, the above-mentioned service ID generation method can be executed, the unique ID is determined based on the cached ID number segment, and it is not necessary to perform a read-write operation to a database, so that the generation efficiency of the unique ID can be improved, and the problem that the throughput of core services such as payment and finance is seriously affected due to a low generation rate of the unique ID in the prior art is solved.
Corresponding to the service ID generation method, an embodiment of the present invention further provides a computer storage medium, where a computer program is stored on the computer storage medium, and the computer program is executed by a processor to execute the service ID generation method in the foregoing embodiment.
Specifically, the storage medium can be a general storage medium, such as a usb disk, a removable disk, a hard disk, an optical disk, and the like, and when a computer program on the storage medium is executed, the service ID generation method can be executed, the unique ID is determined based on the cached ID number segment, and a database does not need to be read and written, so that the generation efficiency of the unique ID can be improved, and the problem that the throughput of core services such as payment and finance is seriously affected due to low generation rate of the unique ID in the prior art is solved.
The service ID generation apparatus provided in the embodiment of the present invention may be specific hardware on the device, or software or firmware installed on the device. The device provided by the embodiment of the present invention has the same implementation principle and technical effect as the method embodiments, and for the sake of brief description, reference may be made to the corresponding contents in the method embodiments without reference to the device embodiments. It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the foregoing systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method may be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and there may be other divisions when actually implemented, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some communication interfaces, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments provided by the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus once an item is defined in one figure, it need not be further defined and explained in subsequent figures, and moreover, the terms "first", "second", "third", etc. are used merely to distinguish one description from another and are not to be construed as indicating or implying relative importance.
Finally, it should be noted that: the above-mentioned embodiments are only specific embodiments of the present invention, which are used for illustrating the technical solutions of the present invention and not for limiting the same, and the protection scope of the present invention is not limited thereto, although the present invention is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: any person skilled in the art can modify or easily conceive the technical solutions described in the foregoing embodiments or equivalent substitutes for some technical features within the technical scope of the present disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the present invention in its spirit and scope. Are intended to be covered by the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (14)

1. A method for generating a service ID, the method comprising:
the method comprises the steps that an ID generation server reads and caches service identifications and ID number sections of a plurality of services from a database server, wherein the service identifications correspond to the ID number sections one by one;
receiving an ID generation request, wherein the ID generation request carries a target service identifier;
if the cache is determined to have a target ID number segment corresponding to the target service identifier, generating a unique ID of the target service in the target ID number segment;
the number of the ID generation servers is multiple, and the unique IDs generated by different ID generation servers in the multiple ID generation servers for the same service each time are different; when any ID generation server acquires the ID number segment from the database server and another ID generation server acquires the ID number segment of the same service from the database server, the ID number segment acquired by the another ID generation server and the ID number segment acquired by any ID generation server are not overlapped.
2. The method of claim 1, wherein caching the service identifiers and the ID number segments of the services comprises:
reading and caching service identifications of a plurality of services stored in a database server;
reading the number segment parameters of the plurality of services stored in the database server;
and determining the ID number segment of each service according to the number segment parameters, and caching the ID number segment of each service.
3. The method of claim 1, further comprising:
if the cache is determined to have no target ID number segment corresponding to the target service identifier, a number segment setting instruction is sent to a database server;
acquiring a target service identifier determined by the database server according to the number segment setting instruction and a target ID number segment corresponding to the target service identifier;
and caching the target service identification and the corresponding target ID number segment thereof, and determining the unique ID of the target service in the target ID number segment.
4. The method of claim 1 or 3, wherein said determining the unique ID of the target traffic in the target ID number segment comprises:
determining a starting value and an ending value of the target ID number segment;
and taking the value which is greater than the preset difference value of the starting value and less than or equal to the ending value as the unique ID.
5. The method of claim 4, further comprising:
updating the start value of the target ID number segment with the unique ID.
6. The method of claim 1, further comprising:
if the ID number segment is determined not to meet the preset requirement, searching a number segment parameter corresponding to the ID number segment in a database server, and updating the ID number segment according to the number segment parameter;
and caching the updated ID number segment.
7. The method of claim 6, further comprising:
determining a start value and an end value of the ID number segment;
and if the initial value is equal to or larger than the termination value, determining that the ID number segment does not meet the preset requirement.
8. The method according to claim 6, wherein the number segment parameters include a termination value of the ID number segment generated last time by the service and a set span of the ID number segment of the service; the updating the ID number segment according to the number segment parameter comprises:
acquiring a termination value of the ID number segment generated in the previous time of the business as an initial value of the updated ID number segment;
and acquiring the sum of the termination value of the ID number segment generated in the previous time of the service and the set span as the updated termination value of the ID number segment.
9. The method of claim 8, further comprising:
detecting the frequency of updating the ID number section according to the number section parameter;
and if the frequency is higher than a preset frequency threshold value, increasing the value of the set span in the number section parameter.
10. A method for generating a service ID, the method comprising:
a load balancing server acquires an ID generation request, determines a target ID generation server for processing the ID generation request from a plurality of ID generation servers, and sends the ID generation request to the target ID generation server;
the ID generation requests carry target service identifications, each ID generation server caches service identifications and ID number segments of a plurality of services, the service identifications correspond to the ID number segments one by one, and the ID number segments corresponding to the same service identification cached in all the ID generation servers are different;
after receiving the ID generation request, the target ID generation server generates a unique ID of a target service in a target ID number segment if the target ID number segment corresponding to the target service identification is determined to be cached;
the unique IDs generated by different ID generation servers in the plurality of ID generation servers for the same service each time are different; when any ID generation server acquires the ID number segment from the database server and another ID generation server acquires the ID number segment of the same service from the database server, the ID number segment acquired by the another ID generation server and the ID number segment acquired by any ID generation server are not overlapped.
11. A service ID generation system is characterized by comprising a load balancing server and a plurality of ID generation servers;
each ID generation server caches service identifications and ID number segments of a plurality of services, wherein the service identifications correspond to the ID number segments one by one, and the ID number segments corresponding to the same service identification cached in all the ID generation servers are different;
the load balancing server is used for determining a target ID generation server for processing an ID generation request in all the ID generation servers and sending the ID generation request to the target ID generation server, wherein the ID generation request carries a target service identifier;
the target ID generation server is used for generating the unique ID of the target service in the target ID number segment if the target ID number segment corresponding to the target service identification is determined to be cached after the ID generation request is received;
the unique IDs generated by different ID generation servers in the plurality of ID generation servers for the same service each time are different; when any ID generation server acquires the ID number segment from the database server and another ID generation server acquires the ID number segment of the same service from the database server, the ID number segment acquired by the another ID generation server and the ID number segment acquired by any ID generation server are not overlapped.
12. A service ID generation apparatus, comprising:
the system comprises a cache module, a database server and an ID generation server, wherein the cache module is used for reading and caching service identifications and ID number sections of a plurality of services from the database server by the ID generation server, and the service identifications correspond to the ID number sections one to one;
the receiving module is used for receiving an ID generation request, and the ID generation request carries a target service identifier;
a determining module, configured to generate a unique ID of the target service in the target ID number segment if it is determined that the cache has the target ID number segment corresponding to the target service identifier;
the number of the ID generation servers is multiple, and the unique IDs generated by different ID generation servers in the multiple ID generation servers for the same service each time are different; when any ID generation server acquires the ID number segment from the database server and another ID generation server acquires the ID number segment of the same service from the database server, the ID number segment acquired by the another ID generation server and the ID number segment acquired by any ID generation server are not overlapped.
13. A computer device comprising a memory and a processor, the memory having stored thereon a computer program operable on the processor, wherein the processor, when executing the computer program, performs the method of any of the preceding claims 1 to 9.
14. A computer storage medium having a computer program stored thereon, the computer program, when executed by a processor, performing the method of any of claims 1 to 9.
CN201710112510.1A 2017-02-28 2017-02-28 Service ID generation method, device and system Active CN106911780B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710112510.1A CN106911780B (en) 2017-02-28 2017-02-28 Service ID generation method, device and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710112510.1A CN106911780B (en) 2017-02-28 2017-02-28 Service ID generation method, device and system

Publications (2)

Publication Number Publication Date
CN106911780A CN106911780A (en) 2017-06-30
CN106911780B true CN106911780B (en) 2020-12-04

Family

ID=59208105

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710112510.1A Active CN106911780B (en) 2017-02-28 2017-02-28 Service ID generation method, device and system

Country Status (1)

Country Link
CN (1) CN106911780B (en)

Families Citing this family (24)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107360224B (en) * 2017-07-07 2020-03-31 携程旅游信息技术(上海)有限公司 Method, system, device and storage medium for generating serial number in distributed system
CN109388626B (en) * 2017-08-04 2023-01-31 北京京东尚科信息技术有限公司 Method and apparatus for assigning numbers to services
CN107885822A (en) * 2017-11-07 2018-04-06 厦门安胜网络科技有限公司 The generation method and device of a kind of operation code
CN108171862B (en) * 2018-01-08 2021-03-09 北京值得买科技股份有限公司 Number sending method and number sender
CN110109912A (en) * 2018-01-15 2019-08-09 北京京东尚科信息技术有限公司 A kind of identifier generation method and device
CN108933822B (en) * 2018-06-28 2019-10-18 北京百度网讯科技有限公司 Method and apparatus for handling information
CN109165712B (en) * 2018-08-01 2021-06-29 广州唯品会信息科技有限公司 Method and device for generating distributed option number and computer storage medium
CN109104490A (en) * 2018-08-29 2018-12-28 北京达佳互联信息技术有限公司 Service identification management method, device, electronic equipment and storage medium
CN109525658A (en) * 2018-11-09 2019-03-26 广州虎牙科技有限公司 A kind of production method, server, equipment, storage medium and operation system
CN111385370B (en) * 2018-12-28 2022-07-08 广州市百果园信息技术有限公司 ID allocation method, device, storage medium and ID allocation system
CN110502536A (en) * 2019-06-26 2019-11-26 中电万维信息技术有限责任公司 Method, apparatus and storage medium based on cache database verification business uniqueness
CN110555078A (en) * 2019-09-02 2019-12-10 上海摩库数据技术有限公司 Distributed ID generation
CN110704128B (en) * 2019-09-29 2023-08-08 北京达佳互联信息技术有限公司 Identification allocation method and device, identification allocation equipment and storage medium
CN110933196B (en) * 2019-11-26 2022-12-06 上海莉莉丝科技股份有限公司 ID distribution method, system and storage medium for global uniform framework
CN111125569A (en) * 2019-12-25 2020-05-08 北京同邦卓益科技有限公司 Data identifier generation method and device, electronic equipment and medium
CN111163186B (en) * 2019-12-31 2023-02-17 南京领行科技股份有限公司 ID generation method, device, equipment and storage medium
CN111353773B (en) * 2020-02-24 2024-01-16 网银在线(北京)科技有限公司 Identification processing method and device, storage medium and electronic device
CN111913956A (en) * 2020-06-28 2020-11-10 中国船舶重工集团公司第七一六研究所 Unified service coding method and device
CN112115133A (en) * 2020-08-04 2020-12-22 北京健康之家科技有限公司 Distributed global unique ID generation method and system, storage medium and device
CN112181306A (en) * 2020-10-10 2021-01-05 杭州电子科技大学 Method for generating distributed ID (identity) in number segment mode
CN112328598B (en) * 2020-11-09 2024-01-09 北京达佳互联信息技术有限公司 ID generation method, ID generation device, electronic equipment and storage medium
CN113064903B (en) * 2021-04-25 2022-12-13 小马国炬(玉溪)科技有限公司 Global ID generation method, device, equipment and storage medium
CN113254207B (en) * 2021-05-26 2024-05-28 北京达佳互联信息技术有限公司 Identification code generation method, device, server and storage medium
CN113553331A (en) * 2021-07-28 2021-10-26 厦门南讯股份有限公司 Database-based multi-service inter-point log ID generation method

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105447023A (en) * 2014-08-25 2016-03-30 阿里巴巴集团控股有限公司 Service identifier generation method and apparatus
CN105630991A (en) * 2015-12-25 2016-06-01 北京奇虎科技有限公司 Method and device for automatically generating ID
CN106341497A (en) * 2016-11-18 2017-01-18 腾讯科技(深圳)有限公司 Digital ID generating method and apparatus

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9418216B2 (en) * 2011-07-21 2016-08-16 Microsoft Technology Licensing, Llc Cloud service authentication
CN104486407B (en) * 2014-12-12 2017-12-19 北京国双科技有限公司 The generation method and device of numbering

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105447023A (en) * 2014-08-25 2016-03-30 阿里巴巴集团控股有限公司 Service identifier generation method and apparatus
CN105630991A (en) * 2015-12-25 2016-06-01 北京奇虎科技有限公司 Method and device for automatically generating ID
CN106341497A (en) * 2016-11-18 2017-01-18 腾讯科技(深圳)有限公司 Digital ID generating method and apparatus

Also Published As

Publication number Publication date
CN106911780A (en) 2017-06-30

Similar Documents

Publication Publication Date Title
CN106911780B (en) Service ID generation method, device and system
CN109949111B (en) Electronic bill identification distribution method, electronic bill generation method, device and system
CN107943594B (en) Data acquisition method and device
CN106649349B (en) Data caching method, device and system for game application
CN106933854B (en) Short link processing method and device and server
US8285690B2 (en) Storage system for eliminating duplicated data
CN109117275B (en) Account checking method and device based on data slicing, computer equipment and storage medium
CN109977129A (en) Multi-stage data caching method and equipment
CN111291079A (en) Data query method and device
CN111028009B (en) Processing method and device for retrievable business entity
CN110677492B (en) Access request processing method and device, electronic equipment and storage medium
CN111722918A (en) Service identification code generation method and device, storage medium and electronic equipment
CN104468399A (en) Data transmission method and device and server
CN107305570B (en) Data retrieval method and system
CN114138840A (en) Data query method, device, equipment and storage medium
US20130304696A1 (en) Online propagation of data updates
CN113377817A (en) Data processing method, system, device and storage medium
CN117473011A (en) Data synchronization method, device and hybrid cache system
CN111061654B (en) Cache refreshing processing method and device and electronic equipment
CN111045988B (en) File searching method, device and computer program product
CN113905252B (en) Data storage method and device for live broadcasting room, electronic equipment and storage medium
JP2018511131A (en) Hierarchical cost-based caching for online media
CN115271861A (en) Request filtering method, device, equipment and storage medium
JP2014524210A (en) Generate variable length nonce
CN114764403A (en) Data migration method, device, equipment and storage medium

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