Inventory deduction method, device, equipment and storage medium

By allocating user requests to the deduction server cluster based on the non-encrypted hash algorithm, the concurrency conflict problem in the high-concurrency inventory deduction system is solved, efficient request processing and cluster expansion are achieved, and the system's responsiveness and cost performance are improved.

CN113762857BActive Publication Date: 2024-09-24BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 16 Cites 0 Cited by

Patent Information

Application Number
CN202011330954.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-24
Publication Date
2024-09-24
Estimated Expiration
2040-11-24

AI Technical Summary

Technical Problem

When the existing technology handles highly concurrent transactions, the inventory deduction system is prone to concurrent database read and write conflicts and resource lock request conflicts, and the peak-shaving and valley-filling and redis hashtag technologies have problems such as low cost performance and difficulty in capacity expansion.

Method used

By obtaining the target item identification associated with the user request, the user request is assigned to the target deduction server in the deduction server cluster based on the preset non-encrypted hash algorithm to realize the deduction of inventory information, and generate feedback based on the deduction response information information to improve request processing efficiency.

Benefits of technology

No additional investment in software and hardware is required, it optimizes the distributed carrying capacity of inventory hotspots, improves the processing efficiency of user requests, simplifies the expansion method of deducting server clusters, and has a cost-effective current limiting effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113762857B
    Figure CN113762857B
Patent Text Reader

Abstract

The embodiment of the present invention discloses an inventory deduction method, device, equipment and storage medium, the method comprising: obtaining a target item identifier associated with a user request, determining a deduction server cluster associated with the target item identifier; assigning the user request to a target deduction server in the deduction server cluster based on a preset non-encrypted hash algorithm according to the user identifier, so that the target deduction server deducts the inventory information of the target deduction server according to the user request; generating request feedback information according to the deduction response information of the target deduction server for response. The method provided by the embodiment of the present invention improves the processing efficiency of user requests by assigning user requests to target deduction servers in the deduction server cluster for responding to user requests based on a non-encrypted hash algorithm.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present invention relate to the field of computer technology, and in particular to an inventory deduction method, device, equipment and storage medium. Background Art

[0002] With the rapid development of the Internet, people's lifestyles have also quietly changed. Online shopping, online ticket booking, online games, online videos, online social networking, etc. have penetrated into people's daily lives. The exponential growth of Internet users has brought severe challenges to operators. Due to the rapid growth of high-concurrency transaction processing requests, the application system crashes due to its inability to support high-concurrency transaction processing capabilities. Taking hot items in the e-commerce field as an example, the number of hot items is limited, so the traffic at the beginning of the activity is very large, and they are all requesting the same resources. Therefore, when deducting inventory, it will cause serious database concurrent read and write conflicts and resource lock request conflicts.

[0003] In the process of realizing the present invention, the inventors found that there are at least the following technical problems in the prior art: There are three main ways to handle the existing inventory hotspots: First, through upstream peak-shaving and valley-filling measures, the peak is staggered so that the number of requests for inventory deductions can reach the range that the system can bear; Second, through the hashtag topic tag technology of redis, the inventory hotspots are broken up and distributed to multiple redis clusters for deduction operations. However, the upstream peak-shaving and valley-filling measures require the support of upstream software and hardware, and the cost-effectiveness is not high. Since the redis tag technology carries a hashtag on the inventory deduction key, it is more troublesome to expand the capacity. At the same time, since the hashtag function is enabled, the overall deduction performance will be affected. Summary of the invention

[0004] The embodiments of the present invention provide an inventory deduction method, device, equipment and storage medium to optimize the distribution of inventory hot spots without additional software and hardware investment, thereby improving the processing efficiency of user requests.

[0005] In a first aspect, an embodiment of the present invention provides an inventory deduction method, including:

[0006] Obtain the target item ID associated with the user request, and determine the deduction server cluster associated with the target item ID;

[0007] According to the user identifier, the user request is assigned to a target deduction server in the deduction server cluster based on a preset non-encrypted hash algorithm, so that the target deduction server deducts the inventory information of the target deduction server according to the user request;

[0008] Generate request feedback information in response to the deduction response information of the target deduction server.

[0009] In a second aspect, an embodiment of the present invention further provides an inventory deduction device, comprising:

[0010] A server cluster determination module, used to obtain the target item identifier associated with the user request and determine the deduction server cluster associated with the target item identifier;

[0011] A user request allocation module, used to allocate the user request to a target deduction server in the deduction server cluster based on a preset non-encrypted hash algorithm according to the user identifier, so that the target deduction server deducts the inventory information of the target deduction server according to the user request;

[0012] The feedback information response module is used to generate request feedback information in response to the deduction response information of the target deduction server.

[0013] In a third aspect, an embodiment of the present invention further provides a computer device, the device comprising:

[0014] one or more processors;

[0015] A storage device for storing one or more programs;

[0016] When one or more programs are executed by one or more processors, the one or more processors implement the inventory deduction method provided by any embodiment of the present invention.

[0017] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the inventory deduction method provided by any embodiment of the present invention.

[0018] The embodiment of the present invention determines the deduction server cluster associated with the target item identifier by obtaining the target item identifier associated with the user request; according to the user identifier, the user request is assigned to the target deduction server in the deduction server cluster based on a preset non-encrypted hash algorithm, so that the target deduction server deducts the inventory information of the target deduction server according to the user request; request feedback information is generated according to the deduction response information of the target deduction server for response, and the user request is assigned to the target deduction server in the deduction server cluster for response to the user request based on the non-encrypted hash algorithm, thereby improving the processing efficiency of the user request. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 is a flow chart of an inventory deduction method provided in Embodiment 1 of the present invention;

[0020] Figure 2 is a flow chart of an inventory deduction method provided by Embodiment 2 of the present invention;

[0021] Figure 3a is a flow chart of an inventory deduction method provided by Embodiment 3 of the present invention;

[0022] Figure 3b It is a schematic diagram of a process of reducing components of a large cluster and expanding capacity provided by the third embodiment of the present invention;

[0023] Figure 3c This is a schematic diagram of a flow chart of requesting current limiting provided by Embodiment 3 of the present invention;

[0024] Figure 3d This is a schematic diagram of a flow chart of user request allocation provided by Embodiment 3 of the present invention;

[0025] Figure 3e This is a schematic diagram of a process of responding to a user request based on a verification keyword provided by Embodiment 3 of the present invention;

[0026] Figure 4 It is a structural schematic diagram of an inventory deduction device provided by the fourth embodiment of the present invention;

[0027] Figure 5 It is a structural diagram of a computer device provided in Embodiment 5 of the present invention. DETAILED DESCRIPTION

[0028] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.

[0029] Embodiment 1

[0030] Figure 1 1 is a flow chart of an inventory deduction method provided in the first embodiment of the present invention. This embodiment is applicable to the case where inventory deduction is performed according to a received user request. The method can be executed by an inventory deduction device, which can be implemented in software and / or hardware. For example, the inventory deduction device can be configured in a computer device. Figure 1 As shown, the method includes:

[0031] S110, obtaining the target item identifier associated with the user request, and determining the deduction server cluster associated with the target item identifier.

[0032] In this embodiment, the user request may be a request initiated by the user through the client to purchase the target item. Exemplarily, the user initiates a purchase operation by operating the terminal to which the client belongs. After the client detects the operation triggered by the user, it generates a user request corresponding to the purchase operation and sends it to the server. After the server detects the user request sent by the client, it parses the user request, obtains the target item identifier contained in the user request, and determines the deduction server cluster corresponding to the target item identifier.

[0033] Among them, the deduction server cluster is pre-configured according to the popularity of the target item, and includes a cluster of multiple deduction servers. Each deduction server corresponds to a virtual cache of the target item. By distributing the cache of the target item to each deduction server in the deduction server cluster, when responding to user requests, the load of user requests is distributed to each deduction server in the deduction server cluster, which solves the problem of limited concurrent capacity of a single server, achieves the effect of dispersing flash sale requests, and improves the responsiveness of the system.

[0034] In one embodiment of the present invention, obtaining the target item identification associated with the user request includes: obtaining the number of requests accumulated by the request counter within a set time period; when the number of requests is within the set number threshold, obtaining the target item identification associated with the user request. When the number of requests is not within the set number threshold, a request failure message is generated as the response information of the user request. Optionally, in order to achieve the flow limit of user requests, the user requests can be screened by counting, which has a very high cost-effectiveness in request flow limit compared to the peak-shaving and valley-filling measures, and does not require additional software and hardware investment. Specifically, when a user request is monitored, the number of requests within the set time period is first accumulated by the counter, and whether to process the user request is determined based on the relationship between the number of requests and the number threshold. When the accumulated number of requests does not reach the set number threshold, the user request is processed, and when the accumulated number of requests reaches the set number threshold, the request failure message is directly returned. For example, a counter can be set in the guava cache. When a user request is detected, the user request first passes through the counter in the guava cache. The counter will be incremented to accumulate the number of requests. When the number of requests reaches the set threshold, such as 4000QPS, the counter will not be incremented, and all subsequent requests will be directly rejected. After reaching the set time period, the counter will be reset to zero, and the number of user requests will be recalculated to decide whether to release or not, and this cycle will repeat. The counter can achieve excellent current limiting at a very low cost. Compared with the peak-shaving and valley-filling method, it does not require too much investment in software and hardware, and has a very high cost-effectiveness.

[0035] S120. According to the user identifier, the user request is distributed to a target deduction server in the deduction server cluster based on a preset non-encrypted hash algorithm, so that the target deduction server deducts the inventory information of the target deduction server according to the user request.

[0036] In this embodiment, after determining the deduction server cluster associated with the target item identifier, a target deduction server is selected from the deduction server cluster to process the user request and perform inventory deduction. The selection of the target deduction server can be determined based on a preset non-encrypted hash algorithm. Preferably, the non-encrypted hash algorithm is the murmur algorithm. The good discreteness and burstability of the murmur algorithm are utilized to ensure the balanced distribution of user requests, thereby ensuring the overall balance of inventory deduction.

[0037] In one embodiment of the present invention, according to the user identifier, the user request is assigned to the target deduction server in the deduction server cluster based on the preset non-encrypted hash algorithm, and further includes: generating a random number according to the inventory keyword associated with the target item identifier; generating a reference value according to the random number and the inventory keyword, and determining the hash value corresponding to the reference value according to the non-encrypted hash algorithm; determining the target deduction server according to the hash value, and assigning the user request to the target deduction server. Optionally, the identifier of the target deduction server is determined by combining the random number generation algorithm with the non-encrypted hash algorithm to assign the user request to the target deduction server. Specifically, when different user requests are associated with the same target item, the inventory keyword of the target item is the same, so it is necessary to generate a random number based on the inventory keyword using a random number generation algorithm (such as a random algorithm), attach the random number to the inventory keyword to obtain a reference value, and then use a non-encrypted hash algorithm (such as a murmur algorithm) to calculate the hash value of the reference value, locate it in the deduction server cluster based on the hash value, and determine the target deduction server. Exemplarily, the deduction server numbered by the hash value can be used as the target deduction server. User requests associated with the same target item are distinguished by combining random numbers with inventory keywords, and the target deduction server is determined by calculating the hash value with the murmur algorithm, so that the distribution of user requests is more balanced, thereby ensuring a more balanced deduction of inventory.

[0038] S130. Generate request feedback information in response to the deduction response information of the target deduction server.

[0039] After the user request is assigned to the target deduction server, the target deduction server performs inventory deduction according to the user request and returns deduction response information, and generates request feedback information according to the deduction response information returned by the target deduction server to respond to the user request. Optionally, the deduction response information returned by the target deduction server may be deduction success information or deduction failure information.

[0040] In one embodiment of the present invention, the deduction response information of the target deduction server is used to generate request feedback information for response, including: when the deduction response information is a successful deduction, request success information is generated as request feedback information; when the deduction response information is a failed deduction, the post-worker is called to retry the deduction, and request feedback information is generated according to the retry deduction result. Specifically, when the deduction response information is a successful deduction, it means that the user request response is successful, and the request success information is generated as request feedback information and sent to the client; when the deduction response information is a failed deduction, it may be due to insufficient inventory or the deduction is successful but the response timeout. In order to distinguish the above two situations, the user request can be sent to the post-worker to retry the deduction. When the post-worker retry deduction is successful, it means that the deduction is successful but the response timeout, that is, the user actually successfully purchased the target item, and the request success information is generated as request feedback information and sent to the client. When the post-worker retry deduction fails, it means that the inventory is insufficient, and the request failure information is generated as request feedback information and sent to the client.

[0041] The embodiment of the present invention determines the deduction server cluster associated with the target item identifier by obtaining the target item identifier associated with the user request; according to the user identifier, the user request is assigned to the target deduction server in the deduction server cluster based on a preset non-encrypted hash algorithm, so that the target deduction server deducts the inventory information of the target deduction server according to the user request; request feedback information is generated according to the deduction response information of the target deduction server for response, and the user request is assigned to the target deduction server in the deduction server cluster for response to the user request based on the non-encrypted hash algorithm, thereby improving the processing efficiency of the user request.

[0042] Embodiment 2

[0043] Figure 2 : is a flow chart of a method for inventory deduction provided by the second embodiment of the present invention. This embodiment is further optimized on the basis of the above solution. Figure 2 As shown, the method includes:

[0044] S210, obtaining reservation information of hot items, and determining the number of deduction servers associated with the hot items according to the reservation information and inventory information of the hot items.

[0045] In this embodiment, the configuration of the deduction server cluster is concretized. Optionally, the deduction server cluster can be configured according to the reservation information and inventory information of the hot items. Exemplarily, the hot items can display a reservation interface to the user before they are put on the shelves. The user can trigger the reservation operation for the hot items through the reservation interface, count the number of reservations for the hot items as the reservation information of the hot items, and use the inventory quantity of the hot items as the inventory information. Combine the reservation information, inventory information and deduction server performance of the hot items to determine the number of deduction servers for the dispersed inventory of the hot items. Theoretically, the larger the reservation information of the target item, the more deduction servers there are, but the number of deduction servers is also limited by the inventory information of the target item to ensure that the inventory quantity allocated on each deduction server is reasonable.

[0046] S220. Configure a deduction server cluster associated with the hot item based on the number of deduction servers.

[0047] After determining the number of deduction servers, configure the corresponding number of deduction servers, organize the configured deduction servers into a deduction server cluster, and then listen to user requests.

[0048] It should be noted that when the configured deduction server cluster cannot handle the current user traffic, the deduction server cluster can be expanded and a new deduction server can be added. Specifically, first delete the deduction cluster keyword, then configure the new deduction server to the deduction server cluster, and restart the engine to achieve smooth expansion.

[0049] S230: Obtain the target item identifier associated with the user request, and determine the deduction server cluster associated with the target item identifier.

[0050] S240. According to the user identifier, the user request is distributed to a target deduction server in the deduction server cluster based on a preset non-encrypted hash algorithm, so that the target deduction server deducts the inventory information of the target deduction server according to the user request.

[0051] S250. Generate request feedback information in response to the deduction response information of the target deduction server.

[0052] The embodiment of the present invention obtains reservation information of hot items, determines the number of deduction servers associated with the hot items according to the reservation information and the inventory information of the hot items; configures the deduction server cluster associated with the hot items based on the number of deduction servers, and flexibly configures the deduction server cluster associated with the hot items through the inventory information and reservation information of the hot items, thereby simplifying the expansion method of the deduction server cluster and having extremely strong cluster adaptive characteristics.

[0053] Embodiment 3

[0054] This embodiment provides a preferred embodiment based on the above embodiments. Figure 3a This is a flow chart of an inventory deduction method provided by Embodiment 3 of the present invention. In this embodiment, the deduction server cluster is concretized as a large deduction cluster, and the deduction server is concretized as a redis deduction cluster. Figure 3a As shown, the method includes:

[0055] S310, reduce the establishment and expansion of large clusters.

[0056] Figure 3b This is a schematic diagram of a process for forming and expanding a large cluster provided by the third embodiment of the present invention, such as Figure 3b As shown in the figure, after docker (application engine) is started, the local configuration is scanned through the routing algorithm. When multiple configured redis deduction clusters are scanned, the ketama hash algorithm is used to form the redis deduction clusters into a large cluster, and then request monitoring is performed. If the current cluster cannot meet the current user traffic, it is necessary to determine the expansion, add a new redis deduction cluster, and expand the large deduction cluster. Since the inventory key is the same in each deduction cluster, there is no possibility of moving the inventory key, so you can directly delete the deductible cluster key, and then configure the new cluster to the configuration file, and restart docker to achieve smooth expansion.

[0057] S320: Monitor user requests and limit the request flow by counting the sliding window.

[0058] Figure 3c : is a schematic diagram of a flow chart of request current limiting provided by the third embodiment of the present invention, such as Figure 3c As shown in the figure, when a user requests to enter for inventory deduction, it first needs to pass through the counter in the guava cache. This counter will be incremented. When the set threshold is reached, such as 4000QPS, the counter will not be incremented, and all subsequent requests will be directly rejected. Since this counter expires after one second, the counter is reset to zero after the next second, and then the number of user requests is recalculated to decide whether to release or not, and this cycle repeats. Excellent current limiting is achieved at a very low cost. Compared with the peak-shaving and valley-filling method, it does not require too much investment in software and hardware, and has a high cost-effectiveness.

[0059] S330. Allocate the user request to the cluster to be deducted by using the murmur algorithm.

[0060] Figure 3d FIG. 1 is a flow chart of a user request allocation process provided by Embodiment 3 of the present invention, such as Figure 3dAs shown in the figure, the uniformity of deduction is guaranteed by the murmur algorithm. Since the inventory key is the same for the deduction of the same product after the user request is entered, it is necessary to use the random algorithm to generate a random number based on the inventory key, and then append the generated random number to the inventory key to get the reference value, and then use the murmur algorithm to calculate the hash value of the reference value, and use the hash value to locate in the large deduction cluster to find the redis cluster to be deducted. Due to the good discreteness and explosiveness of the murmur algorithm, the overall balance of inventory deduction can be guaranteed.

[0061] S340: Respond to the user request according to the verification keyword fed back by the cluster to be deducted.

[0062] Figure 3e FIG. 1 is a flow chart of a method for responding to a user request based on a verification keyword provided in Embodiment 3 of the present invention. Figure 3e As shown, considering that the redis operation may succeed in deduction but time out, and this timeout cannot accurately know whether the inventory has been deducted. Therefore, for each inventory deduction, a deduction verification key will be written on the redis cluster of the current operation to confirm the result of this deduction. The verification key includes various information of this deduction, such as pin information, product information, idempotent information, etc. Since the verification key is written after the inventory deduction, if the verification key is written successfully, it can be considered that the inventory deduction is definitely successful. On the contrary, it can be considered that the inventory deduction is unsuccessful. When the inventory deduction is unsuccessful, the post-positioned worker is used to retry the deduction. If the retry is successful, the deduction success is returned to the user. If the retry fails, the deduction failure is directly returned to the user, and there is no need to do too many retries, because too many retries are very likely to cause over-issuance or under-issuance.

[0063] The embodiment of the present invention implements the flow limiting of requests through sliding window counting, and implements efficient flow limiting measures by using simple components; implements an efficient routing algorithm by combining ketama hash with murmur hash, so that the distribution of requests is more balanced; uses a built-in deductible cluster list to store deductible cluster information, and when a new cluster needs to be added, directly deletes the key of the deductible cluster information, and then modifies the machine configuration and restarts the machine, so as to achieve one-key smooth expansion, simplifying the expansion method.

[0064] Embodiment 4

[0065] Figure 4 Schematic diagram of the structure of a stock deduction device provided in the fourth embodiment of the present invention. The stock deduction device can be implemented in software and / or hardware, for example, the stock deduction device can be configured in a computer device. Figure 4As shown, the device includes a server cluster determination module 410, a user request allocation module 420 and a feedback information response module 430, wherein:

[0066] The server cluster determination module 410 is used to obtain the target item identifier associated with the user request and determine the deduction server cluster associated with the target item identifier;

[0067] A user request allocation module 420 is used to allocate the user request to a target deduction server in the deduction server cluster based on a preset non-encrypted hash algorithm according to the user identifier, so that the target deduction server deducts the inventory information of the target deduction server according to the user request;

[0068] The feedback information response module 430 is used to generate request feedback information in response to the deduction response information of the target deduction server.

[0069] The embodiment of the present invention obtains the target item identification associated with the user request through the server cluster determination module, and determines the deduction server cluster associated with the target item identification; the user request allocation module allocates the user request to the target deduction server in the deduction server cluster based on the user identification and based on a preset non-encrypted hash algorithm, so that the target deduction server deducts the inventory information of the target deduction server according to the user request; the feedback information response module generates request feedback information according to the deduction response information of the target deduction server for response, and improves the processing efficiency of user requests by allocating the user request to the target deduction server in the deduction server cluster based on the non-encrypted hash algorithm to respond to the user request.

[0070] Optionally, based on the above solution, the user request allocation module 420 is specifically used for:

[0071] Generate a random number based on the inventory keyword associated with the target item ID;

[0072] Generate a reference value based on a random number and an inventory keyword, and determine a hash value corresponding to the reference value based on a non-encrypted hash algorithm;

[0073] The target deduction server is determined based on the hash value, and the user request is assigned to the target deduction server.

[0074] Optionally, based on the above solution, the non-encrypted hash algorithm is a murmur algorithm.

[0075] Optionally, based on the above solution, the server cluster determination module 410 is specifically used to:

[0076] Get the number of requests accumulated by the request counter within the set time period;

[0077] When the requested quantity is within the set quantity threshold, the target item ID associated with the user request is obtained.

[0078] Optionally, based on the above solution, the feedback information response module 430 is used to:

[0079] When the number of requests is not within the set number threshold, request failure information is generated as response information to the user request.

[0080] Optionally, based on the above solution, the device further includes a server cluster configuration module, which is used to:

[0081] Obtain reservation information for hot items, and determine the number of deduction servers associated with the hot items based on the reservation information and the inventory information of the hot items;

[0082] Configure the deduction server cluster associated with the hotspot item based on the number of deduction servers.

[0083] Optionally, based on the above solution, the feedback information response module 430 is specifically used to:

[0084] When the deduction response information indicates that the deduction is successful, a request success information is generated as request feedback information;

[0085] When the deduction response information indicates that the deduction has failed, the post-worker is called to retry the deduction, and the request feedback information is generated according to the retry deduction result.

[0086] The inventory deduction device provided in the embodiment of the present invention can execute the inventory deduction method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0087] Embodiment 5

[0088] Figure 5 It is a structural diagram of a computer device provided in Embodiment 5 of the present invention. Figure 5 A block diagram of an exemplary computer device 512 suitable for use in implementing embodiments of the present invention is shown. Figure 5 The computer device 512 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0089] like Figure 5 As shown, the computer device 512 is in the form of a general-purpose computing device. The components of the computer device 512 may include, but are not limited to: one or more processors 516, a system memory 528, and a bus 518 that connects various system components (including the system memory 528 and the processor 516).

[0090] Bus 518 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a local bus to processor 516, or a bus structure using any of a variety of bus architectures. These architectures include, by way of example, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.

[0091] The computer device 512 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the computer device 512, including volatile and non-volatile media, removable and non-removable media.

[0092] System memory 528 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 530 and / or cache memory 532. Computer device 512 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage device 534 may be used to read and write non-removable, non-volatile magnetic media ( Figure 5 not shown, usually called a "hard drive"). Although Figure 5 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 518 via one or more data medium interfaces. The memory 528 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present invention.

[0093] A program / utility 540 having a set (at least one) of program modules 542 may be stored, for example, in the memory 528, such program modules 542 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules 542 generally perform the functions and / or methods of the embodiments described herein.

[0094] The computer device 512 may also communicate with one or more external devices 514 (e.g., keyboard, pointing device, display 524, etc.), may also communicate with one or more devices that enable a user to interact with the computer device 512, and / or communicate with any device that enables the computer device 512 to communicate with one or more other computing devices (e.g., network card, modem, etc.). Such communication may be performed via an input / output (I / O) interface 522. In addition, the computer device 512 may also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN) and / or public network, such as the Internet) via a network adapter 520. As shown, the network adapter 520 communicates with other modules of the computer device 512 via a bus 518. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the computer device 512, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0095] The processor 516 executes various functional applications and data processing by running the program stored in the system memory 528, for example, implementing the inventory deduction method provided in the embodiment of the present invention, which includes:

[0096] Obtain the target item ID associated with the user request, and determine the deduction server cluster associated with the target item ID;

[0097] According to the user identifier, the user request is assigned to a target deduction server in the deduction server cluster based on a preset non-encrypted hash algorithm, so that the target deduction server deducts the inventory information of the target deduction server according to the user request;

[0098] Generate request feedback information in response to the deduction response information of the target deduction server.

[0099] Of course, those skilled in the art can understand that the processor can also implement the technical solution of the inventory deduction method provided by any embodiment of the present invention.

[0100] Embodiment 6

[0101] Embodiment 6 of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, the inventory deduction method provided in the embodiment of the present invention is implemented. The method includes:

[0102] Obtain the target item ID associated with the user request, and determine the deduction server cluster associated with the target item ID;

[0103] According to the user identifier, the user request is assigned to a target deduction server in the deduction server cluster based on a preset non-encrypted hash algorithm, so that the target deduction server deducts the inventory information of the target deduction server according to the user request;

[0104] Generate request feedback information in response to the deduction response information of the target deduction server.

[0105] Of course, the computer-readable storage medium provided by the embodiment of the present invention stores a computer program which is not limited to the above method operations, but can also execute related operations of the inventory deduction method provided by any embodiment of the present invention.

[0106] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.

[0107] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0108] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0109] Computer program code for performing the operations of the present invention may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0110] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims

1. A method of inventory deduction, It is characterized in that include: Obtaining a target item identifier associated with a user request, and determining a deduction server cluster associated with the target item identifier; generating a random number according to an inventory keyword associated with the target item identifier; Generate a reference value according to the random number and the inventory keyword, and determine a hash value corresponding to the reference value according to the non-encrypted hash algorithm; Determine a target deduction server in the deduction server cluster according to the hash value, and distribute the user request to the target deduction server, so that the target deduction server deducts the inventory information of the target deduction server according to the user request; Generate request feedback information in response to the deduction response information of the target deduction server.

2. The method according to claim 1, It is characterized in that The non-encrypted hash algorithm is the murmur algorithm.

3. The method according to claim 1, It is characterized in that Get the target item ID associated with the user request, including: Get the number of requests accumulated by the request counter within the set time period; When the requested quantity is within a set quantity threshold, the target item identifier associated with the user request is obtained.

4. The method according to claim 3, It is characterized in that Also includes: When the request quantity is not within the set quantity threshold, request failure information is generated as response information of the user request.

5. The method according to claim 4, It is characterized in that Also includes: Acquire reservation information of hot items, and determine the number of deduction servers associated with the hot items according to the reservation information and the inventory information of the hot items; A deduction server cluster associated with the hot item is configured based on the number of deduction servers.

6. The method according to claim 1, It is characterized in that The generating request feedback information in response to the deduction response information of the target deduction server includes: When the deduction response information indicates that the deduction is successful, generating request success information as the request feedback information; When the deduction response information indicates that the deduction has failed, the post-worker is called to retry the deduction, and the request feedback information is generated according to the retry deduction result.

7. A stock deduction device, It is characterized in that include: A server cluster determination module, used to obtain a target item identifier associated with a user request, and determine a deduction server cluster associated with the target item identifier; A user request allocation module, configured to generate a random number according to an inventory keyword associated with the target item identifier, generate a reference value according to the random number and the inventory keyword, determine a hash value corresponding to the reference value according to the non-encrypted hash algorithm, determine a target deduction server in the deduction server cluster according to the hash value, and allocate the user request to the target deduction server, so that the target deduction server deducts the inventory information of the target deduction server according to the user request; A feedback information response module is used to generate request feedback information for response based on the deduction response information of the target deduction server.

8. A computer device, It is characterized in that The device comprises: one or more processors; A storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the inventory deduction method as described in any one of claims 1-6.

9. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the program is executed by a processor, the inventory deduction method as described in any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Order processing system of high concurrency competitive inventory and processing method thereof

    CN103426072A

  • Method for message receiving, pushing and transmitting, device, server group and system

    CN103580988A

  • HTTP (Hyper Text Transfer Protocol) request processing method, device and system

    CN107231402A

  • Panic buying request processing method, application server cluster and storage medium

    CN108897615A

  • Performance optimization method of distributed cache server cluster

    CN109218438A