A method, device, equipment and storage medium for processing high-concurrency data requests

By allocating inventory to various partitions in batches, combined with partition operation locks and inventory information management, the hot key problem in high-concurrency data requests was solved, achieving fast and balanced inventory allocation and system stability, and improving user experience.

CN117492990BActive Publication Date: 2026-07-24BEIJING DAJIA INTERNET INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING DAJIA INTERNET INFORMATION TECH CO LTD
Filing Date
2023-11-01
Publication Date
2026-07-24

AI Technical Summary

Technical Problem

In high-concurrency data request scenarios, existing technologies cannot effectively solve the hot key problem, leading to overload of Redis cluster concurrency capacity, abnormal page access, poor user experience, and the sharding method cannot achieve service performance scalability and real-time expansion.

Method used

By allocating inventory from the inventory pool to each partition in small batches, the inventory consumption of each partition is dynamically balanced. A partition operation lock mechanism and partition inventory information management are adopted to achieve fast and balanced inventory allocation.

Benefits of technology

Without exceeding the processing capacity of a single partition, it avoids uneven inventory allocation between partitions, improves system stability and scalability, and reduces the complexity of overall inventory allocation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117492990B_ABST
    Figure CN117492990B_ABST
Patent Text Reader

Abstract

Embodiments of the present disclosure provide a method, device, electronic equipment and storage medium for processing high-concurrency data requests. The method comprises: obtaining a data request sent by a requester; hashing the data request to a first partition in at least one partition; requesting a partition operation lock for the first partition according to the data request; querying partition inventory information of the first partition; in response to no unallocated inventory in the partition inventory, obtaining a batch of inventory from an inventory pool; in response to unallocated inventory in the partition inventory, allocating the unallocated inventory to the data request; and feeding back a data request result to the requester. The method allocates the inventory in the inventory pool to each partition in batches to achieve dynamic balancing of inventory allocation among each partition according to the inventory allocation speed of each partition, thereby achieving fast and balanced inventory allocation. At the same time, the overall inventory allocation complexity is reduced, and the overall work stability is enhanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and more specifically, to a method, apparatus, electronic device, and storage medium for processing high-concurrency data requests. Background Technology

[0002] In today's internet environment, there are many flash sale scenarios. These scenarios create a surge in user demand for a specific "hot key" (e.g., a promotional item in a flash sale) within a short period. During peak times, the large number of users accessing these pages causes a spike in the QPS (Query Per Second). This influx of concurrent requests onto the Redis cluster nodes can easily exceed the Redis nodes' concurrency capacity. The Redis cluster may then be unable to handle the requests and reject them, preventing the front-end page from retrieving data and causing page access errors. This problem is known as the hot key problem.

[0003] To address the aforementioned hot key issue, common techniques include rate limiting or sharding to distribute the access pressure across individual shards. However, rate limiting, limited by the access traffic capacity of a single shard, results in many users being unable to access the service, leading to a poor user experience. While sharding can alleviate the access pressure on individual shards, the varying inventory consumption rates across different shards cause inconsistent progress updates for different users. Furthermore, this approach lacks scalability and extensibility, failing to scale in real-time based on key access demands. In summary, existing solutions to the hot key problem all have shortcomings. Summary of the Invention

[0004] This disclosure provides a method, apparatus, electronic device, and storage medium for handling high-concurrency data requests. The method involves multiple partitions retrieving inventory from an inventory pool in batches, dynamically balancing the consumption of inventory by each partition, and solving the hot key problem.

[0005] According to a first aspect of the present disclosure, a method for processing high-concurrency data requests is provided, comprising: acquiring a data request sent by a requester; the data request including at least: a target data identifier; hashing the data request to a first partition in at least one partition; the at least one partition corresponding to the target data identifier; requesting a partition operation lock from the first partition according to the data request; in response to acquiring the partition operation lock from the data request, querying partition inventory information of the first partition corresponding to the target data identifier; in response to the first partition having no unallocated inventory in its partition inventory, the first partition acquiring a batch of inventory from the inventory pool corresponding to the target data identifier; the batch of inventory including a preset quantity of inventory; reallocating inventory to the data request; in response to the first partition having unallocated inventory in its partition inventory, allocating the unallocated inventory to the data request; and feeding back a data request result to the requester based on the unallocated inventory allocated to the data request.

[0006] In some exemplary embodiments of this disclosure, the partitioned inventory information includes at least: partitioned basic inventory, partitioned batch inventory, and partitioned used inventory; the partitioned basic inventory is used to represent the basic ranking of the current batch inventory of the partition in the inventory pool; the partitioned batch inventory is used to represent the inventory quantity of the current batch inventory of the partition; and the partitioned used inventory is used to represent the quantity of used inventory in the current batch inventory of the partition.

[0007] In some exemplary embodiments of this disclosure, the step of obtaining a batch of inventory from the inventory pool corresponding to the target data identifier in response to the absence of unallocated inventory in the partition inventory of the first partition includes: determining that there is no unallocated inventory in the partition inventory of the first partition when the partition batch inventory of the first partition is equal to the partition used inventory; the first partition sending an inventory acquisition request to the inventory pool corresponding to the target data identifier; in response to the inventory acquisition request, the inventory pool sending first batch inventory information to the first partition; the first batch inventory information includes: first batch basic inventory information and first batch inventory quantity; the first batch basic inventory information is determined based on the allocated inventory quantity in the inventory pool; the first batch inventory quantity is equal to the preset quantity; the first partition updating the partition inventory information of the first partition based on the first batch inventory information.

[0008] In some exemplary embodiments of this disclosure, the step of allocating the unallocated inventory to the data request in response to the presence of unallocated inventory in the partition inventory of the first partition includes: determining that there is unallocated inventory in the partition inventory of the first partition when the partition batch inventory of the first partition is greater than the partition used inventory; and incrementing the partition used inventory of the first partition by one according to the data request to obtain the allocated partition used inventory.

[0009] In some exemplary embodiments of this disclosure, the step of feeding back the data request result to the requester based on the unallocated inventory allocated to the data request includes: determining the data request result based on the unallocated inventory allocated to the data request; the data request result being the sum of the partition base inventory of the first partition and the allocated partition used inventory; and feeding back the data request result to the requester.

[0010] In some exemplary embodiments of this disclosure, the number of data requests to be allocated in each partition is periodically acquired; and the new partition is determined based on the number of data requests to be allocated.

[0011] In some exemplary embodiments of this disclosure, in response to the absence of partition inventory information in the first partition, the first partition is a newly added partition; the first partition obtains the batch of inventory from the inventory pool; and the data request is reallocated to new inventory.

[0012] In some exemplary embodiments of this disclosure, the number of concurrent data requests corresponding to the target data identifier is periodically acquired; and the preset number is determined based on the number of concurrent data requests.

[0013] In some exemplary embodiments of this disclosure, the partition inventory information of each partition is acquired periodically; and the used inventory quantity in the inventory pool is determined based on the partition inventory information of each partition.

[0014] According to a second aspect of the present disclosure, an apparatus for processing high-concurrency data requests is provided, comprising: a data request acquisition module configured to acquire a data request sent by a requester; the data request including at least: a target data identifier; a data request hashing module configured to hash the data request to a first partition in at least one partition; the at least one partition corresponding to the target data identifier; a partition operation lock acquisition module configured to request a partition operation lock from the first partition according to the data request; a partition inventory information query module configured to, in response to the data request, acquire the partition operation lock and query the partition inventory information of the first partition corresponding to the target data identifier; an inventory acquisition module configured to, in response to the first partition having no unallocated inventory in its partition inventory, acquire a batch of inventory from the inventory pool corresponding to the target data identifier; the batch of inventory including a preset quantity of inventory; reallocate inventory to the data request; an inventory allocation module configured to, in response to the first partition having unallocated inventory in its partition inventory, allocate the unallocated inventory to the data request; and a result feedback module configured to, based on the unallocated inventory allocated to the data request, provide a data request result to the requester.

[0015] According to a third aspect of the present disclosure, an electronic device is provided, characterized in that it includes: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to execute the executable instructions to implement the method for processing high-concurrency data requests as described in any one of the present disclosures.

[0016] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided that, when instructions in the computer-readable storage medium are executed by a processor of an electronic device, enables the electronic device to perform any of the methods for processing high-concurrency data requests described in the present disclosure.

[0017] The method for handling high-concurrency data requests provided in this disclosure allocates inventory from a pool to various partitions in batches and in small quantities. This allows the inventory pool to dynamically balance the inventory allocation among partitions based on their allocation speed, thereby avoiding uneven inventory allocation within each partition without exceeding its processing capacity and achieving fast and balanced inventory allocation. Simultaneously, it reduces the overall complexity of inventory allocation and enhances the stability of the overall process.

[0018] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0019] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure. It is obvious that the drawings described below are merely some embodiments of this disclosure, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.

[0020] Figure 1 A schematic diagram of an exemplary system architecture to which the methods of embodiments of this disclosure can be applied is shown.

[0021] Figure 2 This is a flowchart illustrating a method for processing high-concurrency data requests according to an exemplary embodiment.

[0022] Figure 3 This is a flowchart illustrating a method for handling high-concurrency data requests, as shown in an example.

[0023] Figure 4 This is a flowchart illustrating an example of an inventory retrieval method.

[0024] Figure 5 This is a flowchart illustrating an example of an inventory allocation method.

[0025] Figure 6 This is a flowchart illustrating a method for updating the inventory pool's inventory quantity, as shown in an example.

[0026] Figure 7 This is a block diagram illustrating an apparatus for processing high-concurrency data requests according to an exemplary embodiment.

[0027] Figure 8 This is a schematic diagram illustrating the structure of an electronic device suitable for implementing exemplary embodiments of the present disclosure, according to an exemplary embodiment. Detailed Implementation

[0028] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the embodiments set forth herein; rather, they are provided so that this disclosure will be thorough and complete, and will fully convey the concept of the exemplary embodiments to those skilled in the art. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted.

[0029] The features, structures, or characteristics described in this disclosure can be combined in any suitable manner in one or more embodiments. Numerous specific details are provided in the following description to give a thorough understanding of embodiments of this disclosure. However, those skilled in the art will recognize that the technical solutions of this disclosure can be practiced with one or more specific details omitted, or other methods, components, apparatuses, steps, etc., can be employed. In other instances, well-known methods, apparatuses, implementations, or operations are not shown or described in detail to avoid obscuring various aspects of this disclosure.

[0030] The accompanying drawings are merely illustrative of this disclosure, and the same reference numerals in the drawings denote the same or similar parts, thus omitting repeated descriptions of them. Some block diagrams shown in the drawings do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software, in at least one hardware module or integrated circuit, or in different network and / or processor devices and / or microcontroller devices.

[0031] The flowchart shown in the accompanying drawings is merely illustrative and does not necessarily include all content and steps, nor does it require execution in the described order. For example, some steps may be broken down, while others may be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.

[0032] In this specification, the terms “a,” “an,” “the,” “the,” and “at least one” are used to indicate the presence of at least one element / component / etc.; the terms “comprising,” “including,” and “having” are used to indicate an open-ended inclusion and to mean that there may be other elements / components / etc. in addition to the listed elements / components / etc.; the terms “first,” “second,” and “third,” etc., are used only as markings and are not a limitation on the number of objects.

[0033] Figure 1 A schematic diagram of an exemplary system architecture to which the methods of embodiments of this disclosure can be applied is shown.

[0034] like Figure 1 As shown, the system architecture may include server 101, network 102, terminal device 103, terminal device 104, and terminal device 105. Network 102 serves as the medium for providing a communication link between terminal device 103, terminal device 104, or terminal device 105 and server 101. Network 102 may include various connection types, such as wired or wireless communication links or fiber optic cables, etc.

[0035] Server 101 can be a server that provides various services, such as a back-end management server that supports the devices operated by users using terminal devices 103, 104, or 105. The back-end management server can analyze and process received requests and other data, and feed back the processing results to terminal devices 103, 104, or 105.

[0036] Terminal devices 103, 104, and 105 can be smartphones, tablets, laptops, desktop computers, smart speakers, wearable smart devices, virtual reality devices, augmented reality devices, etc., but are not limited to these.

[0037] It should be understood that Figure 1 The number of terminal devices 103, 104, 105, network 102, and server 101 in the diagram is merely illustrative. Server 101 can be a single physical server, a server cluster consisting of multiple servers, or a cloud server. Depending on actual needs, it can have any number of terminal devices, networks, and servers.

[0038] The steps of the method in the exemplary embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings and examples.

[0039] Figure 2 This is a flowchart illustrating a method for processing high-concurrency data requests according to an exemplary embodiment. Figure 3 This is a flowchart illustrating a method for handling high-concurrency data requests, as shown in an example. Figure 2 , 3 The method provided in the embodiments can be executed by any electronic device, such as the one described above. Figure 1 Terminal devices in or Figure 1 The server in, or Figure 1 The terminal devices and servers in the process are executed together, but this disclosure does not limit this.

[0040] In step S210, a data request sent by the requester is obtained; the data request includes at least: a target data identifier.

[0041] In this embodiment of the disclosure, in a flash sale scenario, a large number of requesters send data requests for a specific target hot key. The front end obtains the data requests sent by each requester. Each data request should include at least: a target data identifier. This target data identifier represents the identifier of the target hot key corresponding to the data request. The hot key refers to a popular key in the Redis cluster, such as a promotional product in a flash sale scenario.

[0042] In an exemplary embodiment, different requesters may send their data requests through different platforms or channels, resulting in potentially different data request formats. Therefore, a message generation module can be set up on the front end to process different data requests and generate corresponding data request messages for subsequent processing.

[0043] In step S220, the data request is hashed to a first partition in at least one partition; the at least one partition corresponds to the target data identifier.

[0044] In this embodiment of the disclosure, as mentioned above, the access capacity of a single partition is far from sufficient to meet the user's access needs for a hot key. Therefore, multiple partitions need to be set up corresponding to the target data identifier of the hot key to distribute the access pressure of a single partition. A large number of data requests corresponding to the hot key can be evenly distributed to any partition in at least one partition. Here, the specific number of partitions set for the hot key can be dynamically set according to the concurrency of the hot key (e.g., referring to the QPS of the hot key), or can be manually preset. The first partition can refer to any one of the multiple partitions. The partition can be implemented by an instance of independent hardware or by software partitioning into segments; this embodiment of the disclosure does not limit its implementation form.

[0045] In an exemplary embodiment, hashing refers to transforming an input of arbitrary length into a fixed-length output using a hash algorithm; this output is the hash value. Based on this hash value, the corresponding partition is selected by taking the remainder, thereby evenly distributing data requests to different partitions and balancing the processing load on each partition. The input to this hash algorithm can be the data request, user ID information, or random information such as time information or IP address. Regardless of the information used as input to the hash algorithm, as long as it achieves the goal of evenly distributing data requests to different partitions, it should be considered within the scope of protection of this disclosure. Similarly, using other technical means to evenly distribute the data request should also be within the scope of protection of this disclosure.

[0046] In step S230, a partition operation lock is requested from the first partition according to the data request.

[0047] In this embodiment, after a data request is assigned to a designated first partition, it enters the data request processing queue of that first partition. The first partition establishes a corresponding thread for each data request. Due to the limited processing capacity of the first partition, it is impossible to simultaneously meet the processing needs of all data request threads. To ensure the safety of each thread, a partition operation lock mechanism is set in the first partition. That is, each thread requests the partition operation lock; the thread that acquires the partition operation lock gains the right to perform subsequent operations, while threads that do not acquire the partition operation lock wait for its release and continue to compete for the right to acquire it.

[0048] Furthermore, a partition may process multiple hot keys simultaneously. Therefore, a partition can correspond to different target data identifiers, and different partition operation locks can be set. Data requests corresponding to different target data identifiers will then attempt to acquire their respective partition operation locks.

[0049] In step S240, in response to the data request, the partition operation lock is obtained, and the partition inventory information corresponding to the target data identifier of the first partition is queried.

[0050] In this embodiment of the disclosure, when a thread responding to a data request acquires the partition operation lock, it queries the partition inventory information corresponding to the target data identifier for the first partition. This partition inventory information is used to record the current inventory information of the partition.

[0051] In this embodiment, the inventory pool corresponding to the target data identifier is not directly allocated to each partition all at once, but rather distributed to each partition in small batches. Therefore, the partition inventory information includes at least: partition base inventory, partition batch inventory, and partition used inventory. The partition base inventory B represents the basic ranking of the current batch inventory in the inventory pool. The basic ranking refers to the quantity of inventory already allocated in the inventory pool when allocating the batch inventory to the partition. When allocating the batch inventory to the partition, the inventory pool needs to synchronize the batch base inventory information with the partition. The partition batch inventory N represents the quantity of the current batch inventory in the partition. As mentioned above, the inventory pool distributes a preset quantity of inventory to each partition in small batches, such as N0. The partition batch inventory represents the quantity of batch inventory allocated to that partition. The partition used inventory M represents the quantity of used inventory in the current batch inventory of the partition.

[0052] In an exemplary embodiment, each partition stores its inventory information using key-value pairs in a Redis cluster. A key-value pair is a data structure that stores a correspondence between a key and a value. In this embodiment, the partition's basic inventory, batch inventory, and used inventory can be stored using the following key-value pairs:

[0053] key: ${prefix0}: value: partition base inventory B;

[0054] key: ${prefix1}: value: partition batch inventory N;

[0055] key: ${prefix2}: value: partition used inventory M;

[0056] Among them, prefix0, prefix1, and prefix2 correspond to the basic inventory of the partition, the batch inventory of the partition, and the used inventory of the partition, respectively.

[0057] In an exemplary embodiment, a hot key corresponds to a total inventory quantity of 1000 units, which is placed in the inventory pool corresponding to that hot key. This hot key corresponds to five partitions: partition 1, partition 2, partition 3, partition 4, and partition 5. The inventory pool allocates inventory to each partition in batches according to a preset quantity, assuming the preset quantity N0 = 5. Based on this, the partition inventory information for each partition is shown in Table 1.

[0058] Partition 1 0 5 4 Partition 2 5 5 3 Partition 3 25 5 0 Partition 4 15 5 4 Partition 5 20 5 5

[0059] Table 1

[0060] As shown in the table above, the batch inventory for each partition is allocated to 5 inventory units according to the preset quantity N0 = 5. During initialization, the basic partition inventory B for partitions 1-5 are 0, 5, 10, 15, and 20 respectively. At this time, the allocated inventory quantity in the inventory pool is 25. When the inventory of partition 3 is depleted, a new batch of inventory is requested from the inventory pool, and the basic partition inventory B for this batch is 25. The partition used inventory M represents the quantity of used inventory in the current batch of inventory for that partition. The partition used inventory M for partitions 1-5 are 4, 3, 0, 4, and 5 respectively. Notably, after partition 3 requests a new batch of inventory from the inventory pool, its partition used inventory will be reset.

[0061] In step S250, in response to the absence of unallocated inventory in the partition inventory of the first partition, the first partition obtains a batch of inventory from the inventory pool corresponding to the target data identifier; the batch of inventory includes a preset quantity of inventory; and the data request is reallocated.

[0062] In this embodiment, if it is determined that there is no unallocated inventory in the partition inventory based on the partition inventory information of the first partition, then the first partition obtains a new batch of inventory from the inventory pool corresponding to the target data identifier. In this embodiment, the inventory pool allocates inventory to each partition in small batches. The inventory pool allocates a batch of inventory to the first partition according to a preset quantity. As described in step S240 above, when the inventory pool allocates inventory to the partition, it simultaneously synchronizes the batch inventory information of the batch inventory to the partition, including: batch basic inventory information and batch inventory quantity. After receiving the batch inventory information, the first partition updates its local partition inventory information. After the update is completed, it requests a new inventory allocation for the data.

[0063] In an exemplary embodiment, this preset number is not fixed, but can dynamically change according to the number of concurrent data requests for the hot key. Specifically, it may include the following steps:

[0064] The system periodically acquires information on the number of concurrent data requests corresponding to a target data identifier. This information can be QPS (Query Per Second) or other data that represents the number of concurrent data requests corresponding to the target data identifier. Based on this information, the preset quantity is determined.

[0065] In this embodiment, the real-time traffic status of the hot key corresponding to the target data identifier is understood by periodically acquiring the number of concurrent data requests corresponding to the target data identifier. As the number of concurrent data requests increases, it indicates that the access volume of the hot key is increasing. The preset quantity can be increased to reduce the frequency of batch inventory requests from each partition. This method allows for dynamic adjustment of the preset quantity, making its configuration more flexible.

[0066] In step S260, in response to the presence of unallocated inventory in the partition inventory of the first partition, a data request is made to allocate the unallocated inventory.

[0067] In this embodiment of the disclosure, if it is determined that there is unallocated inventory in the partition inventory based on the partition inventory information of the first partition, then the first partition requests the allocation of the unallocated inventory based on the data.

[0068] In step S270, the data request result is fed back to the requester based on the unallocated inventory allocated in response to the data request.

[0069] In this embodiment of the disclosure, the result of the data request is determined based on the unallocated inventory allocated to the data request, and the result of the data request is fed back to the corresponding requester.

[0070] The method for handling high-concurrency data requests provided in this disclosure allocates inventory from a pool to various partitions in batches and in small quantities. This allows the inventory pool to dynamically balance the inventory allocation among partitions based on their allocation speed, thereby avoiding uneven inventory allocation within each partition without exceeding its processing capacity and achieving fast and balanced inventory allocation. Simultaneously, it reduces the overall complexity of inventory allocation and enhances the stability of the overall process.

[0071] Figure 4 This is a flowchart illustrating an example of an inventory retrieval method. For example... Figure 4 As shown, the aforementioned step S250 may further include the following steps.

[0072] In step S410, when the partition batch inventory of the first partition is equal to the partition used inventory, it is determined that there is no unallocated inventory in the partition inventory of the first partition.

[0073] In this embodiment of the disclosure, as described in step S240 above, the partition inventory information includes at least: partition base inventory B, partition batch inventory N, and partition used inventory M. When the partition batch inventory N of the first partition is equal to the partition used inventory M, it indicates that the batch inventory has been fully allocated, and there is currently no unallocated inventory in the partition inventory.

[0074] In step S420, the first partition sends an inventory retrieval request to the inventory pool corresponding to the target data identifier.

[0075] In this embodiment of the disclosure, the first partition sends an inventory acquisition request to the inventory pool corresponding to the target data identifier. The inventory pool stores the total inventory corresponding to the target data identifier and is used to allocate inventory to each partition in batches.

[0076] In step S430, in response to the inventory acquisition request, the inventory pool sends the first batch of inventory information to the first partition; the first batch of inventory information includes: the first batch of basic inventory information and the first batch of inventory quantity; the first batch of basic inventory information is determined based on the inventory quantity allocated in the inventory pool; the first batch of inventory quantity is equal to the preset quantity.

[0077] In this embodiment, the inventory pool responds to the aforementioned inventory acquisition request by sending the first batch of inventory information to the first partition. This first batch of inventory information includes: first batch basic inventory information and first batch inventory quantity. The first batch basic inventory information corresponds to the aforementioned partition basic inventory B and is determined based on the allocated inventory quantity in the inventory pool. The first batch inventory quantity corresponds to the partition batch inventory N and is equal to the preset quantity N0. Simultaneously, the inventory pool records this first batch of inventory information and updates its local inventory information accordingly. For example, it updates the allocated inventory quantity in the inventory pool for the next batch of inventory allocation.

[0078] In an exemplary embodiment, considering that the inventory pool may not have enough space to allocate a preset quantity N0, or as mentioned above, the preset quantity N0 may dynamically change based on the number of concurrent data requests, the inventory pool needs to send the first batch of inventory quantity to the partition during each batch of inventory allocation.

[0079] In an exemplary embodiment, if the inventory pool uses a fixed preset quantity N0 in each batch of inventory allocation without dynamically changing this quantity, then the inventory pool can send only the basic inventory information for the first batch during each batch of inventory allocation, and the corresponding partition will receive the preset quantity N0 of batch inventory by default.

[0080] In an exemplary embodiment, referring to the example in Table 1 above, when the inventory of partition 3 is depleted, partition 3 sends an inventory retrieval request to the inventory pool. When the inventory pool receives the inventory retrieval request, the inventory pool has allocated an inventory quantity of 25, therefore the basic inventory information for the first batch is 25. The quantity of the first batch inventory is equal to the preset quantity of 5. The inventory pool sends the relevant basic inventory information and the quantity of the first batch inventory to the first partition. Simultaneously, the inventory pool updates its locally allocated inventory quantity to 30.

[0081] In step S440, the first partition updates the partition inventory information of the first partition according to the first batch inventory information.

[0082] In this embodiment of the disclosure, after receiving the first batch of inventory information from the inventory pool, the first partition updates its partition inventory information based on the first batch of inventory information. The update operation specifically includes: using the first batch of basic inventory information as the updated partition basic inventory; using the first batch of inventory quantity as the updated partition batch inventory; and clearing the partition's used inventory to zero.

[0083] Using the inventory acquisition method described above, once the inventory allocation for a given partition is complete, the inventory pool can allocate a batch of inventory to that partition, giving it new unallocated inventory so it can continue to respond to data requests and allocate inventory. Simultaneously, the inventory pool can easily and systematically record the inventory allocation status of each partition, achieving dynamic and orderly inventory allocation.

[0084] Figure 5 This is a flowchart illustrating an example of an inventory allocation method. For example... Figure 5 As shown, the aforementioned step S260 may further include the following steps.

[0085] In step S510, when the partition batch inventory of the first partition is greater than the partition used inventory, it is determined that there is unallocated inventory in the partition inventory of the first partition.

[0086] In this embodiment of the disclosure, as described in step S240 above, the partition inventory information includes at least: partition base inventory B, partition batch inventory N, and partition used inventory M. When the partition batch inventory N of the first partition is greater than the partition used inventory M, it indicates that the batch inventory has not been fully allocated, and there is still unallocated inventory in the current partition inventory.

[0087] In step S520, according to the data request, the partition used inventory of the first partition is incremented by one to obtain the partition used inventory after allocation.

[0088] In this embodiment of the disclosure, based on the partition inventory information of the first partition, it is determined that there is unallocated inventory in the partition inventory. Therefore, it is not necessary to pull a new batch of inventory from the inventory pool. Instead, the first partition requests the allocation of the unallocated inventory based on this data. At the same time, the used inventory M of the aforementioned partition is updated based on the following formula.

[0089] M1 = M0 + 1

[0090] Where M0 is the used inventory of the original partition, and M1 is the used inventory of the partition after allocation.

[0091] like Figure 5 As shown, the aforementioned step S270 may further include the following steps.

[0092] In step S530, the data request result is determined based on the unallocated inventory allocated to the data request; the data request result is the sum of the partition base inventory of the first partition and the allocated partition used inventory.

[0093] In this embodiment of the disclosure, the result of the data request is the ranking of the hot key corresponding to the data request. In a flash sale scenario, a user can determine whether they are eligible to participate based on this ranking information. Therefore, the data request result R can be calculated using the following formula.

[0094] R = B + M1

[0095] Where B represents the partition's base inventory, and M1 represents the partition's used inventory after allocation. The partition's base inventory B is determined by the inventory pool based on the allocated inventory quantity during batch inventory allocation. Adding the allocated partition's used inventory to this base inventory B yields the overall ranking of the data request within the inventory pool corresponding to the hot key.

[0096] In step S540, the data request result is fed back to the requesting party.

[0097] In this embodiment of the disclosure, the ranking information of the data request calculated above is used as the data request result and fed back to the requester to complete the data request process. In a flash sale scenario, users can determine whether they have qualified for the flash sale based on this ranking information.

[0098] The inventory allocation method described above can be used to allocate inventory in response to data requests. Furthermore, it allows for a simple way to determine the ranking of each user for a given hot key in each partition, without requiring ranking aggregation.

[0099] In this embodiment of the disclosure, the number of partitions corresponding to the target data identifier can be manually set or dynamically adjusted based on the accumulated number of data requests to be allocated in each partition. Based on this, this embodiment of the disclosure provides a method for adjusting the number of partitions, which may include the following steps.

[0100] The number of data requests to be allocated in each partition is periodically obtained.

[0101] In this embodiment of the disclosure, the number of data requests to be allocated in each partition is periodically acquired at preset time intervals. This number of data requests to be allocated may be the number of data requests currently pending allocation in the data request processing queue of each partition.

[0102] Based on the quantity information of the data requests to be allocated, the new partition is determined.

[0103] In this embodiment of the disclosure, based on the number of data requests currently awaiting allocation in the data request processing queues of each partition obtained in the above steps, statistical analysis is performed on this number information to determine whether a new partition should be added. This statistical analysis can be implemented in many ways; examples are provided below, but these are not intended to limit the scope of protection of this disclosure.

[0104] In an exemplary embodiment, the data statistics method may be to perform an arithmetic average of the number of data requests to be allocated in each partition. When the average value is greater than a preset threshold, it indicates that the data request processing queues of each partition are severely backlogged, and then a new partition is determined.

[0105] In an exemplary embodiment, the data statistics method may be to sum the number of data requests to be allocated in each partition. When the sum is greater than a preset threshold, it indicates that the overall data request backlog is relatively serious, and then a new partition is determined.

[0106] For this newly added partition, the aforementioned method for handling high-concurrency data requests may also include the following steps.

[0107] If the first partition does not have the partition inventory information, then the first partition is a newly added partition; the first partition obtains the batch of inventory from the inventory pool; and the data request is reallocated to new inventory.

[0108] In this embodiment, since no existing partition inventory information exists for the newly added partition, if no partition inventory information is found when querying partition inventory information in a data request, it indicates that the partition is a newly added partition. For a newly added partition, a batch of inventory needs to be obtained from the inventory pool for inventory allocation. This inventory acquisition process is similar to the aforementioned steps S250, S420, S430, and S440, and will not be repeated here.

[0109] This embodiment of the disclosure periodically acquires information on the number of data requests to be allocated in each partition, monitors the queuing status of data requests in the current partition in real time, and then dynamically adjusts the number of partitions to achieve adaptive hot key traffic changes. Because this method for handling high-concurrency data requests uses a batch approach where each partition retrieves a small amount of inventory from the inventory pool, and determines the result of each data request based on the partition inventory information, there is no need for data aggregation and sorting between partitions, nor for complex work arrangements between partitions. While effectively reducing workload complexity, this gives the entire inventory allocation system excellent scalability and extensibility, allowing for flexible partition expansion in the face of sudden online traffic surges, ensuring overall traffic processing capacity.

[0110] In flash sale scenarios, in addition to knowing each user's individual ranking, it is usually necessary to know the current real-time total used inventory quantity of hot keys. To address this requirement, embodiments of this disclosure provide a method for updating the used inventory quantity of the inventory pool.

[0111] Figure 6 This is a flowchart illustrating a method for updating the used inventory quantity in an inventory pool, as shown in the example. Figure 6 As shown, the inventory pool has an updated inventory quantity method that may include the following steps.

[0112] In step S610, the partition inventory information of each partition is obtained periodically.

[0113] In this embodiment of the disclosure, the partition inventory information of each partition is acquired periodically at preset time intervals. The partition inventory information may further include: the cumulative used inventory quantity of the partition. This cumulative used inventory quantity represents the cumulative allocated inventory quantity of the partition. The cumulative used inventory quantity of the partition can be calculated by adding the partition batch inventory of each partition to the partition used inventory of the current batch. Alternatively, it can be obtained by counting separately each time inventory is allocated.

[0114] In step S620, the quantity of used inventory in the inventory pool is determined based on the partition inventory information of each partition.

[0115] In this embodiment, the used inventory quantity in the inventory pool is obtained by summing the cumulative used inventory quantity in each partition's partition inventory information. The used inventory quantity in this pool provides insight into the current overall flash sale progress.

[0116] In the exemplary embodiments, the above embodiments provide a method for updating the used inventory quantity in an inventory pool. However, the method for updating the used inventory quantity in an inventory pool is not limited to this.

[0117] In step S610, the partition inventory information of each partition is obtained periodically.

[0118] In this embodiment of the disclosure, the partition inventory information of each partition is periodically acquired at preset time intervals. This partition inventory information may further include unreported used inventory. This unreported used inventory represents the quantity of allocated inventory within the current reporting cycle. Since the partition inventory information of each partition is acquired periodically, this acquisition process is the reporting process. The time period from the previous reporting cycle to the current period is the current reporting cycle. The inventory pool periodically polls each partition to obtain the quantity of newly allocated inventory within the current reporting cycle.

[0119] In step S620, the quantity of used inventory in the inventory pool is determined based on the partition inventory information of each partition.

[0120] In this embodiment, the unreported used inventory in the partition inventory information of each partition is accumulated to obtain the total unreported used inventory. This total unreported used inventory represents the total quantity of allocated inventory in the inventory pool corresponding to the target data identifier within the current reporting cycle. This total unreported used inventory is added to the used inventory quantity in the inventory pool determined in the previous round to obtain the used inventory quantity in the current round's inventory pool. This used inventory quantity in the current round's inventory pool is recorded for use in the next round's calculation.

[0121] In this embodiment, the partition inventory information of each partition is acquired periodically and reported to the inventory pool. The inventory pool performs statistical calculations on the partition inventory information of each partition to obtain the total used inventory quantity of the inventory pool corresponding to the hot key, providing a data foundation for understanding the current overall flash sale progress.

[0122] The following are embodiments of the apparatus disclosed herein, which can be used to execute embodiments of the method disclosed herein. For details not disclosed in the apparatus embodiments of this disclosure, please refer to the embodiments of the method disclosed herein.

[0123] Figure 7 This is a block diagram illustrating an apparatus for processing high-concurrency data requests according to an exemplary embodiment. (Refer to...) Figure 7 The device 700 may include: a data request acquisition module 710, a data request hashing module 720, a partition operation lock acquisition module 730, a partition inventory information query module 740, an inventory acquisition module 750, an inventory allocation module 760, and a result feedback module 770.

[0124] The data request acquisition module 710 is configured to acquire a data request sent by the requester; the data request includes at least: a target data identifier;

[0125] A data request hashing module 720 is configured to hash the data request to a first partition in at least one partition; the at least one partition corresponds to the target data identifier.

[0126] The partition operation lock acquisition module 730 is configured to request a partition operation lock from the first partition according to the data request;

[0127] The partition inventory information query module 740 is configured to obtain the partition operation lock in response to the data request and query the partition inventory information of the first partition corresponding to the target data identifier;

[0128] The inventory acquisition module 750 is configured to, in response to the absence of unallocated inventory in the partition inventory of the first partition, acquire a batch of inventory from the inventory pool corresponding to the target data identifier of the first partition; the batch of inventory includes a preset quantity of inventory; and reallocate the inventory to the data request.

[0129] The inventory allocation module 760 is configured to request the allocation of the unallocated inventory in response to the data if there is unallocated inventory in the partition inventory of the first partition.

[0130] The result feedback module 770 is configured to provide the data request result to the requester based on the unallocated inventory allocated in response to the data request.

[0131] In some exemplary embodiments of this disclosure, the partitioned inventory information includes at least: partitioned basic inventory, partitioned batch inventory, and partitioned used inventory; the partitioned basic inventory is used to represent the basic ranking of the current batch inventory of the partition in the inventory pool; the partitioned batch inventory is used to represent the inventory quantity of the current batch inventory of the partition; and the partitioned used inventory is used to represent the quantity of used inventory in the current batch inventory of the partition.

[0132] In some exemplary embodiments of this disclosure, the inventory acquisition module 750 is configured to: determine that there is no unallocated inventory in the partition inventory of the first partition when the partition batch inventory of the first partition is equal to the partition used inventory; send an inventory acquisition request to the inventory pool corresponding to the target data identifier; in response to the inventory acquisition request, the inventory pool sends first batch inventory information to the first partition; the first batch inventory information includes: first batch basic inventory information and first batch inventory quantity; the first batch basic inventory information is determined based on the allocated inventory quantity in the inventory pool; the first batch inventory quantity is equal to the preset quantity; and the first partition updates the partition inventory information of the first partition based on the first batch inventory information.

[0133] In some exemplary embodiments of this disclosure, the inventory allocation module 760 is configured to determine that there is unallocated inventory in the partition inventory of the first partition when the partition batch inventory of the first partition is greater than the partition used inventory; and to increment the partition used inventory of the first partition by one according to the data request to obtain the allocated partition used inventory.

[0134] In some exemplary embodiments of this disclosure, the result feedback module 770 is configured to determine the data request result based on the unallocated inventory allocated to the data request; the data request result is the sum of the partition base inventory of the first partition and the allocated partition used inventory; and to feed back the data request result to the requesting party.

[0135] In some exemplary embodiments of this disclosure, a new partition module is also included, configured to obtain information on the number of data requests to be allocated in each of the partitions; and to determine to add a new partition based on the information on the number of data requests to be allocated.

[0136] In some exemplary embodiments of this disclosure, the inventory acquisition module 750 is configured to, in response to the absence of partition inventory information in the first partition, make the first partition a new partition; the first partition acquires the batch of inventory from the inventory pool; and reallocates the inventory to the data request.

[0137] In some exemplary embodiments of this disclosure, the preset quantity adjustment module is configured to periodically acquire concurrent data request quantity information corresponding to the target data identifier; and determine the preset quantity based on the concurrent data request quantity information.

[0138] In some exemplary embodiments of this disclosure, the used inventory quantity determination module is configured to periodically acquire the partition inventory information of each partition; and determine the used inventory quantity in the inventory pool based on the partition inventory information of each partition.

[0139] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.

[0140] The following reference Figure 8 To describe an electronic device 800 according to such an embodiment of the present disclosure. Figure 8 The electronic device 800 shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments disclosed herein.

[0141] like Figure 8 As shown, the electronic device 800 is presented in the form of a general-purpose computing device. The components of the electronic device 800 may include, but are not limited to: at least one processing unit 810, at least one storage unit 820, a bus 830 connecting different system components (including storage unit 820 and processing unit 810), and a display unit 840.

[0142] The storage unit stores program code, which can be executed by the processing unit 810 to perform the steps described in the "Exemplary Methods" section of this specification according to various exemplary embodiments of this disclosure. For example, the processing unit 810 can perform actions such as... Figure 2 The steps shown.

[0143] For example, electronic devices can achieve such Figure 2 The steps shown.

[0144] Storage unit 820 may include a readable medium in the form of a volatile storage unit, such as random access memory (RAM) 821 and / or cache memory 822, and may further include a read-only memory (ROM) 823.

[0145] The storage unit 820 may also include a program / utility 824 having a set (at least one) of program modules 825, including but not limited to: an operating system, one or more application programs, other program modules, and program data, each or some combination of these examples may include an implementation of a network environment.

[0146] Bus 830 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the various bus structures.

[0147] Electronic device 800 can also communicate with one or more external devices 870 (e.g., keyboard, pointing device, Bluetooth device, etc.), and with one or more devices that enable a user to interact with electronic device 800, and / or with any device that enables electronic device 800 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via input / output (I / O) interface 850. Furthermore, electronic device 800 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 860. As shown, network adapter 860 communicates with other modules of electronic device 800 via bus 830. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 800, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0148] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, terminal device, or network device, etc.) to execute the methods according to the embodiments of this disclosure.

[0149] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory including instructions that can be executed by a processor of the device to perform the described method. Optionally, the computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.

[0150] In an exemplary embodiment, a computer program product is also provided, including a computer program / instructions that, when executed by a processor, implement the methods described above.

[0151] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.

[0152] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.

Claims

1. A method for handling high-concurrency data requests, characterized in that, include: Get the data request sent by the requester; The data request shall include at least: a target data identifier; The data request is hashed to a first partition in at least one partition; the at least one partition corresponds to the target data identifier. Based on the data request, a partition operation lock is requested from the first partition; In response to the data request, obtain the partition operation lock and query the partition inventory information corresponding to the target data identifier for the first partition; If there is no unallocated inventory in the partition inventory of the first partition, the first partition obtains a batch of inventory from the inventory pool corresponding to the target data identifier; the batch of inventory includes a preset quantity of inventory; and the data request is reallocated. In response to the presence of unallocated inventory in the partition inventory of the first partition, a data request is made to allocate the unallocated inventory. Based on the unallocated inventory allocated in response to the data request, the data request result is fed back to the requester.

2. The method according to claim 1, characterized in that, The partitioned inventory information includes at least: partitioned basic inventory, partitioned batch inventory, and partitioned used inventory; The partition base inventory is used to represent the basic ranking of the current batch inventory of the partition in the inventory pool; The partitioned batch inventory is used to represent the inventory quantity of the current batch inventory in the partition. The used inventory of the partition is used to indicate the quantity of used inventory in the current batch of inventory of the partition.

3. The method according to claim 2, characterized in that, In response to the absence of unallocated inventory in the partition inventory of the first partition, the first partition retrieves a batch of inventory from the inventory pool corresponding to the target data identifier, including: When the partition batch inventory of the first partition is equal to the partition used inventory, it is determined that there is no unallocated inventory in the partition inventory of the first partition. The first partition sends an inventory retrieval request to the inventory pool corresponding to the target data identifier; In response to the inventory acquisition request, the inventory pool sends the first batch of inventory information to the first partition; the first batch of inventory information includes: the first batch of basic inventory information and the first batch of inventory quantity; the first batch of basic inventory information is determined based on the inventory quantity already allocated in the inventory pool; the first batch of inventory quantity is equal to the preset quantity; The first partition updates its partition inventory information based on the first batch inventory information.

4. The method according to claim 2, characterized in that, The step of requesting the allocation of unallocated inventory in response to the presence of unallocated inventory in the partition inventory of the first partition includes: When the partition batch inventory of the first partition is greater than the partition used inventory, it is determined that there is unallocated inventory in the partition inventory of the first partition. Based on the data request, the used inventory of the first partition is incremented by one to obtain the used inventory of the allocated partition.

5. The method according to claim 4, characterized in that, The step of feeding back the data request result to the requester based on the unallocated inventory allocated according to the data request includes: The data request result is determined based on the unallocated inventory allocated to the data request; the data request result is the sum of the partition base inventory of the first partition and the allocated partition used inventory; The data request result is fed back to the requesting party.

6. The method according to claim 1, characterized in that, Also includes: Periodically obtain information on the number of data requests to be allocated in each of the partitions; Based on the number of data requests to be allocated, the new partition is determined.

7. The method according to claim 1 or 6, characterized in that, Also includes: If the first partition does not have the partition inventory information, then the first partition is a newly added partition; The first partition retrieves the batch of inventory from the inventory pool; The data request is used to reallocate inventory.

8. The method according to claim 1, characterized in that, Also includes: Periodically obtain the number of concurrent data requests corresponding to the target data identifier; The preset quantity is determined based on the concurrent data request quantity information.

9. The method according to claim 1, characterized in that, Also includes: Periodically obtain the partition inventory information of each partition; The quantity of used inventory in the inventory pool is determined based on the partition inventory information of each partition.

10. An apparatus for processing high-concurrency data requests, characterized in that, include: The data request acquisition module is configured to acquire data requests sent by the requester. The data request shall include at least: a target data identifier; A data request hashing module is configured to hash the data request to a first partition in at least one partition; the at least one partition corresponds to the target data identifier. The partition operation lock acquisition module is configured to request a partition operation lock from the first partition based on the data request; The partition inventory information query module is configured to obtain the partition operation lock in response to the data request and query the partition inventory information of the first partition corresponding to the target data identifier; The inventory acquisition module is configured to, in response to the absence of unallocated inventory in the partition inventory of the first partition, acquire a batch of inventory from the inventory pool corresponding to the target data identifier of the first partition; the batch of inventory includes a preset quantity of inventory; and reallocate the inventory based on the data request. The inventory allocation module is configured to request the allocation of unallocated inventory in response to the data if there is unallocated inventory in the partition inventory of the first partition. The result feedback module is configured to provide the data request result to the requester based on the unallocated inventory allocated in response to the data request.

11. An electronic device, characterized in that, include: processor; Memory used to store the processor's executable instructions; The processor is configured to execute the executable instructions to implement the method for processing high-concurrency data requests as described in any one of claims 1 to 9.

12. A computer-readable storage medium, wherein instructions in the computer-readable storage medium, when executed by a processor of an electronic device, enable the electronic device to perform the method for processing high-concurrency data requests as claimed in any one of claims 1 to 9.