Request processing method and apparatus, electronic device, and storage medium

By obtaining the resource threshold, cumulative consumption information, and consumption prediction information of shared resources, resource requests are processed directly, solving the problem of low request processing efficiency in distributed systems and achieving efficient, fast request response and consistent operation.

CN113900831BActive Publication Date: 2026-01-20BEIJING DAJIA INTERNET INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111182112.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-11
Publication Date
2026-01-20
Estimated Expiration
2041-10-11

AI Technical Summary

Technical Problem

In existing technologies, the processing efficiency of shared resource requests in distributed systems is low, the response is slow, and the processing pressure is high, especially under high concurrency request conditions.

Method used

By obtaining the resource threshold, cumulative resource consumption information, and resource consumption prediction information within the time window of the shared resources, the total resource consumption information is determined. If the total resource consumption information is less than the resource threshold, the resource request is processed directly, reducing the number of times the distributed lock is used. Combining the time window with resource consumption prediction improves request processing efficiency and consistency.

Benefits of technology

It improves the efficiency and response speed of request processing, reduces processing pressure, and maintains operational consistency of shared resources in high-concurrency scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113900831B_ABST
    Figure CN113900831B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a request processing method and device, electronic equipment and storage medium. The method comprises: when a target resource request for a shared resource is received, obtaining resource threshold corresponding to the shared resource, resource cumulative consumption information, and resource consumption prediction information within a time window, the termination time of the time window being the current time; determining resource total consumption information according to the resource consumption prediction information and the resource cumulative consumption information; and processing the target resource request if the resource total consumption information is less than the resource threshold. According to the technical solution provided by the present disclosure, the efficiency of request processing can be improved and the operation consistency of the shared resource can be ensured.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the technical field of data processing, and particularly relates to a request processing method and device, electronic equipment and storage medium. BACKGROUND

[0002] With the wide use of distributed systems, the contention for shared resources (shared content) in the distributed system is concerned. In the related art, the server of the distributed system, for example, the Redis (Remote Dictionary Server) server, selects to use a distributed lock to solve the problem of contention for shared resources and can maintain the operation consistency of the shared resources. The process of the distributed lock is: contending for the distributed lock, reading and writing the shared content after successfully contending for the lock, and releasing the lock, as shown in FIG. 1. Although the use of the distributed lock solves the problems of contention for shared resources and consistency, it causes the processing efficiency of the request to be low, the response to be slow, and the processing pressure to be large. In the case of high concurrency of requests, these problems are more serious. Figure 1 SUMMARY

[0003] The present disclosure provides a request processing method and device, electronic equipment and storage medium to at least solve the problem of how to improve the efficiency of shared resource requests and guarantee the operation consistency of shared resources in the related art. The technical solutions of the present disclosure are as follows.

[0004] According to a first aspect of an embodiment of the present disclosure, a request processing method is provided, comprising:

[0005] When a target resource request for a shared resource is received, resource threshold information corresponding to the shared resource, resource cumulative consumption information, and resource consumption prediction information in a time window are obtained, and the end time of the time window is the current time;

[0006] According to the resource consumption prediction information and the resource cumulative consumption information, resource total consumption information is determined;

[0007] In the case where the resource total consumption information is less than the resource threshold, the target resource request is processed.

[0008] In a possible implementation manner, before the step of processing the target resource request in the case where the resource total consumption information is less than the resource threshold, the method further comprises:

[0009] The resource threshold information corresponding to the weight information is obtained;

[0010] According to the resource threshold and the weight information, a target resource threshold is determined;

[0011] ​The processing of the target resource request in the case that the total resource consumption information is less than a resource threshold comprises:

[0012] Processing the target resource request in the case that the total resource consumption information is less than a target resource threshold.

[0013] In a possible implementation, before the step of obtaining the resource consumption prediction information in the time window, the method further comprises:

[0014] Obtaining a preset time length;

[0015] Determining the time window according to the preset time length and the current time.

[0016] In a possible implementation, the step of obtaining the preset time length comprises:

[0017] Obtaining processing time statistical information corresponding to historical resource requests of the shared resource;

[0018] Obtaining the preset time length based on the processing time statistical information.

[0019] In a possible implementation, before the step of obtaining the resource consumption prediction information in the time window, the method further comprises:

[0020] Obtaining at least one first historical resource request of the shared resource before the current time, and a current state of the first historical resource request is a non-end state;

[0021] Determining at least one time length from a historical receiving time of each of the at least one first historical resource request to the current time;

[0022] Determining the time window according to a maximum time length in the at least one time length and the current time.

[0023] In a possible implementation, the step of obtaining the resource consumption prediction information in the time window comprises:

[0024] Obtaining historical resource request information corresponding to a second historical resource request of the shared resource in the time window, and target resource request information corresponding to the target resource request in the time window;

[0025] Determining the resource consumption prediction information according to the target resource request information and the historical resource request information.

[0026] In a possible implementation, the method further comprises:

[0027] In a case where the total resource consumption information is greater than or equal to the resource threshold, determine distributed lock state information of the target resource request;

[0028] Based on the distributed lock state information, perform corresponding processing on the target resource request.

[0029] According to a second aspect of the embodiments of the present disclosure, a request processing apparatus is provided, comprising:

[0030] The obtaining module is configured to, when a target resource request for a shared resource is received, obtain a resource threshold corresponding to the shared resource, resource cumulative consumption information, and resource consumption prediction information within a time window, a terminal time of the time window being a current time;

[0031] The total resource consumption information determination module is configured to determine total resource consumption information according to the resource consumption prediction information and the resource cumulative consumption information.

[0032] The first request processing module is configured to, in a case where the total resource consumption information is less than the resource threshold, perform processing on the target resource request.

[0033] In a possible implementation, the apparatus further comprises:

[0034] The weight information obtaining module is configured to obtain weight information corresponding to the resource threshold.

[0035] The target resource threshold determination module is configured to determine a target resource threshold according to the resource threshold and the weight information.

[0036] The request processing module comprises:

[0037] The request processing unit is configured to, in a case where the total resource consumption information is less than the target resource threshold, perform processing on the target resource request.

[0038] In a possible implementation, the apparatus further comprises:

[0039] The preset time length obtaining module is configured to obtain a preset time length.

[0040] The first time window determination module is configured to determine the time window according to the preset time length and the current time.

[0041] In a possible implementation, the preset time length obtaining module comprises:

[0042] The time statistical unit is configured to obtain processing time statistical information corresponding to historical resource requests of the shared resource.

[0043] The preset time length obtaining unit is configured to obtain the preset time length based on the processing time statistical information.

[0044] In a possible implementation, the apparatus further includes:

[0045] The first historical resource request obtaining module is configured to obtain at least one first historical resource request for the shared resource before the current time, and a current state of the first historical resource request is a non-end state.

[0046] The time length determining module is configured to determine at least one time length from a historical receiving time of each of the at least one first historical resource request to the current time.

[0047] The second time window determining module is configured to determine the time window according to a maximum time length in the at least one time length and the current time.

[0048] In a possible implementation, the obtaining module includes:

[0049] The obtaining unit is configured to obtain historical resource request information corresponding to a second historical resource request for the shared resource in the time window and target resource request information corresponding to the target resource request in the time window.

[0050] The resource consumption prediction information determining unit is configured to determine the resource consumption prediction information according to the target resource request information and the historical resource request information.

[0051] In a possible implementation, the apparatus further includes:

[0052] The distributed lock determining module is configured to determine distributed lock state information of the target resource request in a case where the total resource consumption information is greater than or equal to the resource threshold.

[0053] The second request processing module is configured to perform corresponding processing on the target resource request based on the distributed lock state information.

[0054] According to a third aspect of the embodiments of the present disclosure, an electronic device is provided, including a processor, a memory for storing instructions executable by the processor, and wherein the processor is configured to execute the instructions to implement the method according to any one of the first aspect.

[0055] According to a fourth aspect of the embodiments of the present disclosure, a computer readable storage medium is provided. When instructions in the computer readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the method according to any one of the first aspect of the embodiments of the present disclosure.

[0056] According to a fifth aspect of the embodiments of the present disclosure, a computer program product is provided, comprising computer instructions, which, when executed by a processor, cause a computer to perform the method according to any one of the first aspect of the embodiments of the present disclosure.

[0057] The technical solutions provided by the embodiments of the present disclosure at least have the following beneficial effects:

[0058] By combining the resource consumption prediction information with the actual resource cumulative consumption information, the total resource consumption information is obtained. In the case that the total resource consumption information is less than the resource threshold, the resource request is directly processed. By this pre-judgment of whether to use the distributed lock before the distributed lock is grabbed, the number of uses of the distributed lock can be reduced, the efficiency of request processing can be improved, the request response can be faster, and the processing pressure can be greatly reduced. This processing method can also effectively adapt to high-concurrency scenarios. In addition, since the time window is set to realize the prediction of resource consumption, the total resource consumption information can take into account the resource request information corresponding to the requests that have not ended, thereby improving the comprehensiveness and accuracy of the total resource consumption information, so that the request processing efficiency is improved, and the operation consistency of the shared resources can also be guaranteed.

[0059] It should be understood that the foregoing general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. BRIEF DESCRIPTION OF DRAWINGS

[0060] The accompanying drawings, which are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification, serve to explain the principles of the present disclosure, and do not constitute an improper limitation on the present disclosure.

[0061] Figure 1 is a use diagram of a distributed lock in an existing distributed system.

[0062] Figure 2 is a schematic diagram of an application environment according to an exemplary embodiment.

[0063] Figure 3 is a flowchart of a request processing method according to an exemplary embodiment. Figure 1 .

[0064] Figure 4 is a schematic diagram of a time window according to an exemplary embodiment.

[0065] Figure 5 is a flow of a request processing method according to an exemplary embodiment Figure 2 .

[0066] Figure 6 is a flow of a request processing method according to an exemplary embodiment Figure 3 .

[0067] Figure 7 is a flowchart of a method of determining a time window according to an exemplary embodiment.

[0068] Figure 8 is a flowchart of another method of determining a time window according to an exemplary embodiment.

[0069] Figure 9 is a schematic diagram of a first historical resource request according to an exemplary embodiment.

[0070] Figure 10 is a block diagram of a request processing apparatus according to an exemplary embodiment.

[0071] Figure 11 is a block diagram of an electronic device for request processing according to an exemplary embodiment. DETAILED DESCRIPTION

[0072] In order to make the ordinary person skilled in the art better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be described clearly and completely below in conjunction with the drawings.

[0073] It should be noted that the terms "first", "second", and the like in the specification and claims of the present disclosure and the above-described drawings are used to distinguish similar objects, and do not necessarily have to describe a specific order or a chronological sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present disclosure described herein can be implemented in an order other than that illustrated or described herein. The implementation described in the following exemplary embodiments does not represent all the implementations consistent with the present disclosure. Rather, they are only examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0074] Please refer to Figure 2 , Figure 2 is a schematic diagram of an application environment according to an exemplary embodiment, as Figure 2 shown, the application environment can include a server 01 and a terminal 02.

[0075] In an optional embodiment, the server 01 can be used for processing the request. Specifically, the server 01 can be a server in a distributed system, and as an example, the server 01 can be a Redis server.

[0076] In an optional embodiment, the terminal 02 can be used to send a resource request. Specifically, the terminal 02 can include, but is not limited to, a smartphone, a desktop computer, a tablet computer, a notebook computer, a smart speaker, a digital assistant, an augmented reality (AR) / virtual reality (VR) device, a smart wearable device, and the like. Optionally, the operating system running on the electronic device can include, but is not limited to, an Android system, an IOS system, Linux, Windows, and the like.

[0077] In addition, it should be noted that, Figure 2 The above is only one application environment of the request processing method provided by the present disclosure.

[0078] In the embodiments of the present disclosure, the server 01 and the terminal 02 described above can be connected directly or indirectly through wired or wireless communication, which is not limited in the present application.

[0079] It should be noted that the steps shown in the following figures are only one possible order, and in fact, it is not necessarily strictly in this order. Some steps can be executed in parallel without mutual dependence. The user information (including but not limited to user device information, user personal information, user behavior information, etc.) and data (including but not limited to data for display, training data, etc.) involved in the present disclosure are all information and data authorized by the user or authorized by all parties.

[0080] Figure 3 is a flow of a request processing method according to an example embodiment Figure 1 As shown in Figure 3 , it can include the following steps.

[0081] In step S301, a target resource request for a shared resource is received, and resource threshold information corresponding to the shared resource, resource cumulative consumption information, and resource consumption prediction information within a time window are obtained.

[0082] The termination time of the time window can be the current time, and the time length of the time window can be a preset time length. In an example, the preset time length can be 5 seconds, which is not limited in the present disclosure.

[0083] In an example, the shared resource can refer to a resource shared by each request, such as inventory of a preset object, refund amount, etc., and the preset object can be a commodity, a virtual service, etc. The resource threshold can refer to a limit value of the shared resource, such as a maximum amount of refund, etc. The resource cumulative consumption information (S) can refer to cumulative information of the shared resource consumed, such as a cumulative sum of resource consumption information corresponding to each of the resource requests that have been processed and ended, and taking the refund amount as an example, it can refer to a cumulative sum of refund amounts corresponding to each of the resource requests that have been processed and ended. The resource cumulative consumption information and the resource threshold can be stored in a server, such as a Redis server; the resource threshold can be pre-set, and the resource cumulative consumption information S can be updated by using the incrBy command in Redis to accumulate. It should be noted that as an example, one kind of shared resource can correspond to one kind of resource request, so that the corresponding shared resource can be determined according to the resource request, and the present disclosure does not limit this.

[0084] In actual application, when the target resource request for the shared resource is received, the stored resource threshold and resource cumulative consumption information can be obtained, and the target resource request can be one or more. The resource consumption prediction information in the time window can be obtained, the target resource request is in the time window, the request in the time window can be obtained, and the sum of the resource request information (resource consumption information) carried in the request in the time window can be taken as the resource consumption prediction information. For example, the resource consumption prediction information in the time window can be obtained by the following steps:

[0085] Obtaining historical resource request information corresponding to the second historical resource request for the shared resource in the time window, and target resource request information corresponding to the target resource request in the time window;

[0086] According to the target resource request information and the historical resource request information, the resource consumption prediction information is determined.

[0087] In an example, the resource consumption prediction information W can be obtained by using the following formula (1):

[0088]

[0089] Wherein, Z i is the historical resource request information corresponding to the i-th second historical resource request in the time window; n is the number of second historical resource requests in the time window; Z 目标 is the target resource request information corresponding to the target resource request in the time window.

[0090] For example, as Figure 4As shown, the start time of the time window is t, and the end time is the current time. The time window contains 3 resource requests: 2 second historical resource requests and 1 target resource request. Among them, the 2 second historical resource requests are R1 and R2, R1 corresponds to the historical resource request information Z1 (the resource request information carried in R1) of 20 pieces, and R2 corresponds to the historical resource request information Z2 of 50 pieces; the target resource request is R3, and the corresponding target resource request information Z 目标 As shown, the start time of the time window is t, and the end time is the current time. The time window contains 3 resource requests: 2 second historical resource requests and 1 target resource request. Among them, the 2 second historical resource requests are R1 and R2, R1 corresponds to the historical resource request information Z1 (the resource request information carried in R1) of 20 pieces, and R2 corresponds to the historical resource request information Z2 of 50 pieces; the target resource request is R3, and the corresponding target resource request information Z 目标 As shown, the start time of the time window is t, and the end time is the current time. The time window contains 3 resource requests: 2 second historical resource requests and 1 target resource request. Among them, the 2 second historical resource requests are R1 and R2, R1 corresponds to the historical resource request information Z1 (the resource request information carried in R1) of 20 pieces, and R2 corresponds to the historical resource request information Z2 of 50 pieces; the target resource request is R3, and the corresponding target resource request information Z

[0091] Alternatively, the resource threshold, the resource cumulative consumption information and the resource consumption prediction information can correspond to one merchant, that is, the resource threshold, the resource cumulative consumption information and the resource consumption prediction information under one merchant. Correspondingly, when the target resource request for the shared resource is received, the merchant identifier can be extracted from the target resource request, so that the resource threshold, the resource cumulative consumption information and the resource consumption prediction information corresponding to the shared resource under the target merchant corresponding to the merchant identifier can be obtained. As an example, the resource threshold and the resource cumulative consumption information can correspond to a time period, for example, the resource threshold and the resource cumulative consumption information of the day, and correspondingly, at 0:00 of the day, the resource threshold and the resource cumulative consumption information can be cleared respectively.

[0092] In a possible scenario, in the case that the target resource request corresponds to a merchant, the terminal can send the target resource request to the corresponding merchant, and the corresponding merchant can judge whether the target resource request satisfies a preset condition. If yes, the target resource request is forwarded to the server. The preset condition can be preset by the merchant, for example, in the case that the shared resource is a refund amount, the preset condition can be that the single amount, the refund reason and the refund time respectively satisfy a preset single amount, a preset refund reason and a preset refund time, and the present disclosure does not limit the preset single amount, the preset refund reason and the preset refund time.

[0093] In step S303, the total resource consumption information is determined according to the resource consumption prediction information and the resource cumulative consumption information.

[0094] In actual application, the resource consumption prediction information in the time window can refer to an estimation of consumption of shared resources by concurrent requests in the time window. Based on this, the sum of the resource consumption prediction information and the resource cumulative consumption information is determined as the resource total consumption information, which can improve the accuracy of resource consumption prediction at the current time.

[0095] In step S305, if the resource total consumption information is less than the resource threshold, the target resource request is processed.

[0096] In the embodiments of the present specification, if the resource total consumption information is less than the resource threshold, the resource request can be directly processed, for example, the target resource corresponding to the target resource request information of the target resource request can be allocated to the client corresponding to the target resource request from the resource threshold, and after successful allocation, the resource cumulative consumption information can be updated according to the target resource request information, for example, the target resource request information can be added to the resource cumulative consumption information to obtain updated resource cumulative consumption information. Taking the above example, 20 pieces can be allocated to the client of the target resource request from the inventory; and after successful allocation, the updated resource cumulative consumption information can be obtained by adding the 20 pieces to the resource cumulative consumption information, for example, 100 pieces. Alternatively, if the allocation is unsuccessful, it can be determined that the target resource request is ended.

[0097] By combining the resource consumption prediction information with the actual resource cumulative consumption information to obtain the resource total consumption information, and directly processing the resource request if the resource total consumption information is less than the resource threshold, the use of the distributed lock can be pre-judged before the distributed lock is acquired, which can reduce the number of uses of the distributed lock, improve the efficiency of request processing, and make the request response faster. The processing pressure can also be greatly reduced, and this processing method can also effectively adapt to high-concurrency scenarios. In addition, since the time window is set to predict the resource consumption, the resource total consumption information can take into account the resource request information corresponding to the requests that have not ended, which improves the comprehensiveness and accuracy of the resource total consumption information, thereby improving the request processing efficiency while ensuring the operation consistency of the shared resources.

[0098] Figure 5 is a flowchart of another request processing method according to an example embodiment Figure 2 In a possible implementation manner, as shown in Figure 5 , the method can further include:

[0099] In step S501, if the resource total consumption information is greater than or equal to the resource threshold, the distributed lock state information of the target resource request is determined.

[0100] In step S503, the target resource request is processed based on the distributed lock state information.

[0101] In actual application, when the total resource consumption information is greater than or equal to the resource threshold, the processing mode of using the distributed lock can be degraded, as shown in the following table. Figure 1 As shown in the table, the competition of the distributed lock can be performed first, if the target resource request competes for the distributed lock, it can be determined that the distributed lock state information of the target resource request is that the distributed lock is acquired, in this case, the target resource request can be processed, that is, the shared resource can be read and written, and after the reading and writing are completed, the distributed lock can be released. If the target resource request does not compete for the distributed lock, it can be determined that the distributed lock state information of the target resource request is that the distributed lock is not acquired, in this case, it can be determined that the target resource request is completed.

[0102] By degrading the processing mode of using the distributed lock when the total resource consumption information is greater than or equal to the resource threshold, the rationality of the request processing can be further ensured.

[0103] Figure 6 is a flow of a request processing method according to an example embodiment Figure 3 . As shown in Figure 6 , before S305, the method can further include:

[0104] In step S601, weight information corresponding to the resource threshold is obtained.

[0105] In step S603, a target resource threshold is determined according to the resource threshold and the weight information.

[0106] Correspondingly, S305 can include:

[0107] In step S605, the resource request is processed when the total resource consumption information is less than the target resource threshold. The implementation of this step can refer to S305, which will not be repeated here.

[0108] In actual application, there can be resource requests before the start time of the time window, which have not been processed at the current time, so that the resource consumption prediction information in the time window is not accurate enough, but this situation generally does not occur. In order to ensure the processing efficiency and take this situation into account, some resources can be reserved for the requests in this situation, for example, one tenth of the resource threshold can be reserved, and the present disclosure does not limit this. In this case, the weight information can correspond to the reserved proportion, for example, the weight information can be 0.9. Based on this, in an example, the product of the weight information and the resource threshold can be used as the target resource threshold for judgment in the request processing, for example, the resource request can be processed when the total resource consumption information is less than the target resource threshold.

[0109] By setting the weight information corresponding to the resource threshold, the request processing efficiency can be improved while considering some resource requests with longer processing time, making the request processing judgment more accurate, thereby improving the operation success rate of shared resources.

[0110] Figure 7 is a method flow chart for determining a time window according to an exemplary embodiment. As shown in S305, it can also include: Figure 7

[0111] In step S701, a preset time length is obtained.

[0112] In the embodiments of the present specification, the preset time length can be pre-set, such as 5 seconds, which can be obtained from the storage space.

[0113] In one possible implementation, the step S701 can include the following steps:

[0114] Obtain the processing time statistical information corresponding to the resource request of the shared resource;

[0115] Based on the processing time statistical information, obtain the preset time length.

[0116] In the original distributed lock scheme, after competing for the distributed lock, a series of strategy matching and execution request processing operations are required, and the resource cumulative consumption information is updated only after the operation is successful. Based on this, the processing time of historical resource requests can be counted to obtain the processing time statistical information, for example, 5 seconds, which can be used as the preset time length. By obtaining the preset time length through statistical means, the preset time length can be more in line with the actual situation, providing a guarantee for accurate determination of the time window.

[0117] In step S703, the time window is determined according to the preset time length and the current time.

[0118] In actual application, the time window can be determined according to the preset time length and the current time, i.e. the termination time of the time window can be determined as the current time, and the time length of the time window can be determined as the preset time length.

[0119] By setting the preset time length and combining the current time, the time window is determined, so that the time window can be the nearest time period from the current time, which can ensure the timeliness of the resource consumption prediction information, and avoid that the historical resource requests that have ended are counted in the time window, thereby reducing the statistical pressure and improving the prediction efficiency and accuracy of the resource consumption prediction information.

[0120] The above Figure 6 ​A case is introduced that there can be resource requests before the start time of a time window, and the resource requests are not processed at the current time, which makes the resource consumption prediction information in the time window not accurate enough. Figure 6 A solution is given in the corresponding part. Another solution is given below, which can also effectively take into account this case and improve the accuracy of the resource consumption prediction information in the time window.

[0121] Figure 8 is a flowchart of another method for determining a time window according to an example embodiment. In a possible implementation, as shown in Figure 8 The step S305 can include:

[0122] In step S801, at least one first historical resource request for a shared resource before the current time is obtained, and the current state of the first historical resource request is a non-end state;

[0123] In step S803, at least one time length of each historical receiving time of the at least one first historical resource request from the current time is determined.

[0124] In step S805, a time window is determined according to the maximum time length in the at least one time length and the current time.

[0125] In an example, as shown in Figure 9 R1 before the current time has been executed and ended, i.e., in an end state. Based on this, the first historical resource request can include R0 and R2, and the current state of R0 and R2 is a non-end state. Here, the resource request corresponding to the maximum time length of the historical receiving time from the current time is R0, where the historical receiving time can be the time when the server receives the first historical resource request, or can refer to the time when the first historical resource request arrives at the server. Further, the time window can be determined according to the time length corresponding to R0 and the current time. For example, the termination time of the time window can be determined as the current time, the time length of the time window can be determined as the maximum time length, and accordingly, the start time of the time window is t0, as shown in Figure 9 .

[0126] By dynamically determining the time length of the time window, the length of the time window is not fixed and is more flexible; only when the historical resource request is executed (execution ends), the start time of the time window is moved to the time point of the next request, so that the time window can contain all the executing resource requests, and the prediction accuracy of the resource consumption prediction information is improved; thereby making the request processing more accurate, and further improving the operation success rate of the shared resource.

[0127] Figure 10 is a block diagram of a request processing device according to an example embodiment. Referring toFigure 10 The apparatus can comprise:

[0128] The obtaining module 1001 is configured to, when a target resource request for a shared resource is received, obtain resource threshold information corresponding to the shared resource, resource cumulative consumption information, and resource consumption prediction information within a time window, the end time of the time window being the current time;

[0129] The resource total consumption information determination module 1003 is configured to determine resource total consumption information according to the resource consumption prediction information and the resource cumulative consumption information;

[0130] The first request processing module 1005 is configured to, when the resource total consumption information is less than the resource threshold, process the target resource request.

[0131] By combining the actual resource cumulative consumption information with the resource consumption prediction information, the resource total consumption information is obtained, and when the resource total consumption information is less than the resource threshold, the resource request is directly processed. By making a pre-judgment of whether to use a distributed lock before acquiring the distributed lock, the number of times of using the distributed lock can be reduced, the efficiency of request processing can be improved, the request response can be faster, and the processing pressure can be greatly reduced. This processing method can also effectively adapt to high-concurrency scenarios. In addition, since the time window is set to predict the resource consumption, the resource total consumption information can take into account the resource request information corresponding to the requests that have not ended, thereby improving the comprehensiveness and accuracy of the resource total consumption information, so that the request processing efficiency is improved, and the operation consistency of the shared resource can also be guaranteed.

[0132] In a possible implementation manner, the apparatus can further comprise:

[0133] The weight information obtaining module is configured to obtain weight information corresponding to the resource threshold;

[0134] The target resource threshold determination module is configured to determine a target resource threshold according to the resource threshold and the weight information;

[0135] The request processing module comprises:

[0136] The request processing unit is configured to, when the resource total consumption information is less than the target resource threshold, process the target resource request.

[0137] In a possible implementation manner, the apparatus can further comprise:

[0138] The preset time length obtaining module is configured to obtain a preset time length;

[0139] The first time window determination module is configured to determine the time window according to a preset time length and a current time.

[0140] In a possible implementation, the preset time length obtaining module comprises:

[0141] The time statistics unit is configured to obtain processing time statistics information corresponding to the historical resource requests for the shared resource.

[0142] The preset time length obtaining unit is configured to obtain the preset time length based on the processing time statistics information.

[0143] In a possible implementation, the apparatus can further comprise:

[0144] The first historical resource request obtaining module is configured to obtain at least one first historical resource request for the shared resource before the current time, and a current state of the first historical resource request is a non-end state.

[0145] The time length determination module is configured to determine at least one time length from a current time to a historical receiving time of each of the at least one first historical resource request.

[0146] The second time window determination module is configured to determine the time window according to a maximum time length in the at least one time length and the current time.

[0147] In a possible implementation, the obtaining module 1001 can comprise:

[0148] The obtaining unit is configured to obtain historical resource request information corresponding to a second historical resource request for the shared resource in the time window and target resource request information corresponding to a target resource request in the time window.

[0149] The resource consumption prediction information determination unit is configured to determine the resource consumption prediction information according to the target resource request information and the historical resource request information.

[0150] In a possible implementation, the apparatus can further comprise:

[0151] The distributed lock determination module is configured to determine distributed lock state information of the target resource request in a case where the total resource consumption information is greater than or equal to a resource threshold.

[0152] The second request processing module is configured to perform corresponding processing on the target resource request based on the distributed lock state information.

[0153] As to the apparatus in the above-described embodiments, the specific manners in which various modules perform operations have been described in details in the embodiments of the method, and will not be described in details here.

[0154] Figure 11 is a block diagram of an electronic device for request processing according to an example embodiment, which can be a server, and its internal structure can be as shown in Figure 11 The electronic device includes a processor, a memory and a network interface connected through a system bus. The processor of the electronic device is configured to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operating system and the computer program in the non-volatile storage medium to run. The network interface of the electronic device is configured to communicate with an external terminal through a network connection. The computer program is executed by the processor to implement a request processing method.

[0155] Those skilled in the art can understand that Figure 11 The structure shown in the above is only a block diagram of part of the structure related to the present disclosure, and does not constitute a limitation on the electronic device to which the present disclosure is applied. The specific electronic device can include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0156] In an example embodiment, an electronic device is also provided, including a processor, a memory for storing instructions executable by the processor, and wherein the processor is configured to execute the instructions to implement a request processing method as in the embodiments of the present disclosure.

[0157] In an example embodiment, a computer readable storage medium is also provided, when the instructions in the computer readable storage medium are executed by the processor of the electronic device, the electronic device can execute the request processing method in the embodiments of the present disclosure. The computer readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device, etc.

[0158] In an example embodiment, a computer program product containing instructions is also provided, when it is run on a computer, the computer executes the request processing method in the embodiments of the present disclosure.

[0159] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer readable storage medium. When the computer program is executed, the processes of the above-mentioned embodiments of the methods can be included. Any reference to memory, storage, databases, or other media in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM is available in many forms such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0160] Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure that are deemed to fall within the general principles of the disclosure and include commonly known or customary practice in the art. The specification and examples are to be considered exemplary only, with the true scope and spirit of the disclosure being indicated by the following claims.

[0161] It should be understood that the present disclosure is not limited to the precise structures as herein described and illustrated in the drawings, and that various modifications and changes can be made without departing from the scope thereof. The scope of the present disclosure is limited only by the claims that follow.

Claims

1. A request processing method characterized by comprising: The application is applied to a distributed system, comprising: When a target resource request for a shared resource is received, resource threshold information corresponding to the shared resource, resource cumulative consumption information, and resource consumption prediction information in a time window are obtained, the end time of the time window being the current time; the time window is the nearest time period to the current time; wherein the resource consumption prediction information is obtained by obtaining historical resource request information corresponding to a second historical resource request for the shared resource in the time window, and target resource request information corresponding to the target resource request in the time window; the resource consumption prediction information is determined according to the sum of the target resource request information and the historical resource request information; According to the resource consumption prediction information and the resource cumulative consumption information, the total resource consumption information is determined; the resource cumulative consumption information is the cumulative sum of all processed resource requests corresponding to the resource consumption information; In the case where the total resource consumption information is less than the resource threshold, a distributed lock is not used, and the target resource request is directly processed.

2. The request processing method according to claim 1, characterized by, Before the step of processing the target resource request in the case where the total resource consumption information is less than the resource threshold, the method further comprises: Obtaining weight information corresponding to the resource threshold; According to the resource threshold and the weight information, a target resource threshold is determined; The step of processing the target resource request in the case where the total resource consumption information is less than the target resource threshold comprises: In the case where the total resource consumption information is less than the target resource threshold, the target resource request is processed.

3. The request processing method according to claim 2, characterized by, Before the step of obtaining resource consumption prediction information in the time window, the method further comprises: Obtaining a preset time length; According to the preset time length and the current time, the time window is determined.

4. The request processing method according to claim 3, characterized by, The step of obtaining a preset time length comprises: Obtaining processing time statistical information corresponding to historical resource requests of the shared resource; Based on the processing time statistical information, the preset time length is obtained.

5. The request processing method according to claim 1, characterized by, Before the step of obtaining resource consumption prediction information in the time window, the method further comprises: Obtaining at least one first historical resource request for the shared resource before the current time, the current state of the first historical resource request being a non-end state; Determining at least one time length from the historical receiving time of the at least one first historical resource request to the current time; According to the maximum time length in the at least one time length and the current time, the time window is determined.

6. The request processing method of claim 1, wherein, The method further comprises: In the case where the total resource consumption information is greater than or equal to the resource threshold, the distributed lock state information of the target resource request is determined; Based on the distributed lock state information, the target resource request is processed accordingly.

7. A request processing apparatus characterized by comprising: Comprise: The acquisition module is configured to acquire resource threshold information, resource cumulative consumption information, and resource consumption prediction information in a time window when a target resource request for a shared resource is received, the time window ending at a current time; the time window is the nearest time period to the current time; the acquisition module includes: an acquisition unit configured to acquire historical resource request information corresponding to a second historical resource request for the shared resource in the time window and target resource request information corresponding to the target resource request in the time window; a resource consumption prediction information determination unit configured to determine the resource consumption prediction information according to a sum of the target resource request information and the historical resource request information; The resource total consumption information determination module is configured to determine resource total consumption information according to the resource consumption prediction information and the resource cumulative consumption information; the resource cumulative consumption information is a cumulative sum of resource consumption information corresponding to all processed resource requests; The first request processing module is configured to directly process the target resource request without using a distributed lock when the resource total consumption information is less than the resource threshold.

8. The request processing apparatus according to claim 7, characterized by The device further includes: The weight information acquisition module is configured to acquire weight information corresponding to the resource threshold; The target resource threshold determination module is configured to determine a target resource threshold according to the resource threshold and the weight information; The request processing module includes: The request processing unit is configured to process the target resource request when the resource total consumption information is less than the target resource threshold.

9. The request processing apparatus according to claim 8, characterized by The device further includes: The preset time length acquisition module is configured to acquire a preset time length; The first time window determination module is configured to determine the time window according to the preset time length and the current time.

10. The request processing apparatus according to claim 9, characterized by The preset time length acquisition module includes: The time statistics unit is configured to acquire processing time statistics information corresponding to historical resource requests for the shared resource; The preset time length acquisition unit is configured to acquire the preset time length based on the processing time statistics information.

11. The request processing apparatus according to claim 7, characterized by The device further includes: The first historical resource request acquisition module is configured to acquire at least one first historical resource request for the shared resource before the current time, the current state of the first historical resource request being a non-end state; The time length determination module is configured to determine at least one time length from a historical receiving time of the at least one first historical resource request to the current time; The second time window determination module is configured to determine the time window according to a maximum time length in the at least one time length and the current time.

12. The request processing apparatus according to claim 7, characterized by The device further includes: The distributed lock determination module is configured to determine distributed lock state information of the target resource request when the resource total consumption information is greater than or equal to the resource threshold. A second request processing module is configured to perform corresponding processing on the target resource request based on the distributed lock state information.

13. An electronic device, comprising: The application relates to a computer readable storage medium storing computer instructions, wherein the computer instructions are executed by a processor of an electronic device to enable the electronic device to perform the request processing method. The application relates to a computer readable storage medium storing computer instructions, wherein the computer instructions are executed by a processor of an electronic device to enable the electronic device to perform the request processing method. The application relates to a computer readable storage medium storing computer instructions, wherein the computer instructions are executed by a processor of an electronic device to enable the electronic device to perform the request processing method. The application relates to a computer readable storage medium storing computer instructions, wherein the computer instructions are executed by a processor of an electronic device to enable the electronic device to perform the request processing method.

14. A computer-readable storage medium, characterized in that, ​ 15. A computer program product comprising computer instructions, characterized in that, ​