Access request processing method and device, storage medium and electronic equipment
By obtaining access control parameters to limit the number of access requests and adopting flexible forwarding strategies, the problem of service instability caused by a large number of access requests to object storage services in a short period of time was solved, and stable service provision was achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
- Filing Date
- 2021-11-24
- Publication Date
- 2026-08-04
AI Technical Summary
In existing technologies, object storage services cannot reliably provide response services when receiving a large number of access requests in a short period of time, resulting in excessive load on the object interface.
By obtaining the access control parameters of the stored object, the number of access requests per unit time is limited, and access requests are rejected when the total number of requests exceeds the limit. Different forwarding strategies are used to forward requests when the limit is not exceeded, and token bucket algorithm and fixed window algorithm are flexibly switched to control the access frequency.
Access control to storage objects is controlled, avoiding service instability caused by a large number of access requests in a short period of time, and ensuring that storage objects can provide stable services.
Smart Images

Figure CN116170163B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computers, and more specifically, to a method, apparatus, storage medium, and electronic device for processing access requests. Background Technology
[0002] In existing technologies, object storage that provides massive storage services can store a large number of objects, which users can access to obtain corresponding services. However, if a user accesses a particular object too frequently, that object will receive a large number of access requests in a short period of time. But the object cannot provide a response service to such a large number of access requests.
[0003] In other words, in existing technologies, if the number of access requests to stored objects is too large in a short period of time, it will cause a heavy load on the object interface, and the object will be unable to stably provide services for the access requests. Summary of the Invention
[0004] This invention provides a method, apparatus, storage medium, and electronic device for processing access requests, to at least solve the technical problem that an object cannot reliably provide services for access requests.
[0005] According to one aspect of the present invention, a method for processing access requests is provided, comprising: upon receiving a target access request for accessing a target storage object, obtaining access control parameters for the target storage object, wherein the access control parameters are used to control the number of access requests for accessing the target storage object per unit time; if the total number of the target access request and other access requests for accessing the target storage object per unit time exceeds the access control parameters, rejecting the target access request for accessing the target storage object, wherein the other access requests are requests for accessing the target storage object received before the target access request; and if the total number of the target access request and other access requests is less than or equal to the access control parameters, forwarding the target access request to a target access interface of the target storage object, so that the target account that sent the target access request can access the target storage object.
[0006] According to another aspect of the present invention, an access request processing apparatus is provided, comprising: an acquisition module, configured to acquire access control parameters of the target storage object when a target access request for accessing the target storage object is acquired, wherein the access control parameters are used to control the number of access requests for accessing the target storage object per unit time; a processing module, configured to reject the target access request for accessing the target storage object when the total number of the target access request and other access requests for accessing the target storage object per unit time exceeds the access control parameters, wherein the other access requests are requests for accessing the target storage object received before the target access request; and a first forwarding module, configured to forward the target access request to a target access interface of the target storage object when the total number of the target access request and other access requests is less than or equal to the access control parameters, so that the target account that sent the target access request can access the target storage object.
[0007] As an optional example, the first forwarding module includes: a first forwarding unit, configured to forward the target access request to the target access interface using a first forwarding strategy when the first number of the target access request and the other access requests received within the target time period of receiving the target access request is greater than or equal to a first threshold; and a second forwarding unit, configured to forward the target access request to the target access interface using a second forwarding strategy when the first number is less than the first threshold.
[0008] As an optional example, the first forwarding unit includes: an acquisition subunit, configured to acquire one or more tokens from a token bucket, wherein tokens are generated in the token bucket at a predetermined frequency, the generated tokens are stored in the token bucket, and the tokens are used to transmit the access request to the corresponding access interface; a first determination subunit, configured to determine the acquired one or more tokens as target tokens; and a first forwarding subunit, configured to use the target tokens to forward the target access request to the target access interface.
[0009] As an optional example, the first forwarding unit further includes: a processing subunit, configured to wait for the token bucket to generate a new token if the number of tokens in the token bucket is less than the number of tokens of the target token; and a second determining subunit, configured to use the tokens in the token bucket as the target token if the number of tokens in the token bucket is equal to the number of tokens of the target token.
[0010] As an optional example, the second forwarding unit includes: a statistics subunit, used to count the number of access requests that have been forwarded before the target access request is forwarded within the target time period; a second forwarding subunit, used to forward the target access request to the target access interface in a first time period after the target time period if the number of already forwarded access requests is greater than or equal to a second threshold, wherein the second threshold is the maximum number of access requests allowed to be forwarded within the target time period, and the first time period is equal in length to the target time period; and a third forwarding subunit, used to forward the target access request to the target access interface within the target time period if the number of already forwarded access requests is less than the second threshold.
[0011] As an optional example, the first forwarding module further includes: a first adjustment unit, configured to, when forwarding the target access request using the first forwarding strategy, adjust the forwarding of the target access request from using the first forwarding strategy to using the second forwarding strategy when the first quantity changes from being greater than or equal to the first threshold to being less than the first threshold; and a second adjustment unit, configured to, when forwarding the target access request using the second forwarding strategy, adjust the forwarding of the target access request from using the second forwarding strategy to using the first forwarding strategy when the first quantity changes from being less than the first threshold to being greater than or equal to the first threshold.
[0012] As an optional example, the above-mentioned acquisition module includes: a first acquisition unit, configured to acquire the access control parameters configured for the target storage object when the target access request is to perform a read operation on the target storage object, wherein the access control parameters are used to control the number of access requests to read the target storage object per unit time; a second acquisition unit, configured to acquire the access control parameters configured for the target storage object when the target access request is to perform a write operation on the target storage object, wherein the access control parameters are used to control the number of access requests to write data to the target storage object per unit time; and a third acquisition unit, configured to acquire the access control parameters configured for the target storage object when the target access request is to perform both read and write operations on the target storage object, wherein the access control parameters are used to control the number of access requests to perform both read and write operations on the target storage object per unit time.
[0013] As an optional example, the above apparatus further includes: a determining module, configured to determine the memory space occupied by the target access request and the other access requests; and a second forwarding module, configured to, when the occupied space reaches the maximum capacity of the memory, directly forward the new access request to the corresponding access interface upon receiving the new access request.
[0014] According to another aspect of the present invention, a storage medium is also provided, wherein a computer program is stored therein, wherein the computer program is executed by a processor to perform the above-described method for processing access requests.
[0015] According to another aspect of the present invention, an electronic device is also provided, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to execute the access request processing method described above through the computer program.
[0016] In this embodiment of the invention, upon receiving a target access request for accessing a target storage object, access control parameters for the target storage object are obtained. These access control parameters control the number of access requests to the target storage object per unit time. If the total number of the target access request and other access requests to the target storage object per unit time exceeds the access control parameters, the target access request is rejected. These other access requests are requests received before the target access request. If the total number of the target access request and other access requests is less than or equal to the access control parameters, the target access request is forwarded to the target access interface of the target storage object, allowing the target account that sent the target access request to access the target storage object. Because this method checks whether the total number of access requests to the target storage object exceeds a limit upon receiving an access request, and rejects access if the limit is exceeded, access to the target storage object is controlled. This avoids a large number of access requests to the storage object in a short period, preventing the storage object from providing stable services, and thus solves the technical problem of the object being unable to stably provide services to access requests. Attached Figure Description
[0017] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:
[0018] Figure 1This is a flowchart of an optional access request processing method according to an embodiment of the present invention;
[0019] Figure 2 This is a schematic diagram of a proxy server forwarding an access request, according to an optional access request processing method based on an embodiment of the present invention.
[0020] Figure 3 This is a schematic diagram of a token bucket for an optional access request processing method according to an embodiment of the present invention;
[0021] Figure 4 This is a schematic diagram illustrating the forwarding of an access request using an optional access request processing method according to an embodiment of the present invention.
[0022] Figure 5 This is a flowchart of an optional access request processing method according to an embodiment of the present invention;
[0023] Figure 6 This is a schematic diagram of the structure of an optional access request processing device according to an embodiment of the present invention;
[0024] Figure 7 This is a schematic diagram of an optional electronic device according to an embodiment of the present invention. Detailed Implementation
[0025] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0026] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0027] According to a first aspect of the present invention, a method for processing access requests is provided, optionally, as follows: Figure 1 As shown, the above method includes:
[0028] S102, when a target access request for accessing the target storage object is obtained, the access control parameters of the target storage object are obtained, wherein the access control parameters are used to control the number of access requests to access the target storage object per unit time.
[0029] S104, if the total number of the target access request and other access requests to access the target storage object within a unit time exceeds the access control parameter, the target access request is denied access to the target storage object, wherein the other access requests are requests to access the target storage object received before the target access request.
[0030] S106, if the total number of target access requests and other access requests is less than or equal to the access control parameters, forward the target access request to the target access interface of the target storage object so that the target account that sent the target access request can access the target storage object.
[0031] Optionally, the storage object in this embodiment can be an object stored on a server for providing services. The services provided by the storage object can be invoked by calling its access interface.
[0032] In this embodiment, the access control parameters can be parameters pre-configured for each storage object. The access control parameters for different storage objects can be the same or different.
[0033] In this embodiment, the access control parameters constrain the number of access requests to the target storage object within a unit of time. If the number of other access requests to the target storage object within a unit of time reaches the access control parameters, then after receiving the target access request, the total number of the target access request and other access requests exceeds the access control parameters, and the target access request will not be forwarded to the target access interface of the target storage object. If the number of other access requests does not reach the access control parameters, then after receiving the target access request, the total number of the target access request and other access requests does not exceed the access control parameters. In this case, the target access request can be forwarded to the target access interface for access.
[0034] Optionally, the unit time in this embodiment can be a preset time. By setting the unit time and access control parameters, the maximum number of access requests to a certain storage object within a certain time period can be determined.
[0035] In this embodiment, the above-described method for processing access requests can be applied to a proxy server. For example, as... Figure 2As shown in Figure 2, the proxy server is responsible for forwarding access requests to the access interface. Different access requests are sent to the proxy server, which then forwards the access requests to the access interface of the storage object requested by the access request.
[0036] Through this embodiment and the above method, when an access request to access the target storage object is received, it can be checked whether the total number of access requests to the target storage object exceeds the limit. If the limit is exceeded, access to the target storage object is rejected, thereby realizing access control of the target storage object and avoiding a situation where a large number of access requests to the storage object in a short period of time cause the storage object to be unable to provide stable services.
[0037] As an optional example, the target access interface that forwards the target access request to the target storage object when the total number of the target access request and other access requests currently accessing the target storage object is less than or equal to the access control parameter includes:
[0038] If, within the target time period after receiving the target access request, the first number of the target access request and other access requests received is greater than or equal to the first threshold, the first forwarding strategy is adopted to forward the target access request to the target access interface.
[0039] If the first number is less than the first threshold, the second forwarding strategy is used to forward the target access request to the target access interface.
[0040] Optionally, in this embodiment, if the target access request can be forwarded to the target access interface, different forwarding strategies can be used to control the forwarding of the target access request. This embodiment can use the total number of access requests received within a target time period to determine the forwarding strategy for the target access request. The target time period can be the same as or different from the unit time period. The system counts whether the number of access requests received within the target time period is greater than a first threshold. If it is greater than the first threshold, the first forwarding strategy is adopted; if the number of access requests is less than the first threshold, the second forwarding strategy is adopted.
[0041] In this embodiment, the first threshold can be a pre-configured value, and the forwarding frequency of the first forwarding strategy and the second forwarding strategy are different.
[0042] As an optional example, the above-mentioned method of forwarding the target access request to the target access interface using the first forwarding strategy when the first number of the target access request and other access requests received within the target time period of receiving the target access request is greater than or equal to a first threshold includes:
[0043] Obtain one or more tokens from the token bucket, wherein tokens are generated in the token bucket at a predetermined frequency, the generated tokens are stored in the token bucket, and the tokens are used to transmit access requests to the corresponding access interface;
[0044] Identify one or more acquired tokens as the target token;
[0045] Use the target token to forward the target access request to the target access interface.
[0046] Optionally, in this embodiment, the token bucket is a storage area for producing and storing tokens. The token bucket produces tokens at a predetermined frequency, and after production, the tokens are stored in the token bucket. Therefore, the token bucket contains tokens. When forwarding a target access request to the target access interface, the target token is retrieved from the token bucket for forwarding the target access request. Forwarding the target access request may use one or more tokens; therefore, the number of tokens required is determined by retrieving the appropriate number from the token bucket for forwarding. Once a token is retrieved from the token bucket, it is used and no longer stored in the token bucket. For example, as... Figure 3 As shown, Figure 3 In the token bucket 302, tokens 304 are included, and new tokens 304 are generated at a predetermined frequency and stored in the token bucket 302. When forwarding a target access request, token 304 is obtained from the token bucket 302 and the target access request is forwarded to the target access interface.
[0047] As an optional example, the above method also includes:
[0048] If the number of tokens in the token bucket is less than the number of tokens for the target token, wait for the token bucket to generate new tokens;
[0049] If the number of tokens in the token bucket equals the number of tokens in the target token, then the tokens in the token bucket are used as the target token.
[0050] Optionally, in this embodiment, the tokens in the token bucket may not be sufficient for forwarding the target access request. If there are not enough tokens in the token bucket, the target access request will not be forwarded temporarily. Instead, the system will wait for tokens to be generated in the token bucket. Once there are enough tokens to forward the target access request, the tokens in the token bucket will be used as the target tokens to forward the target access request. The target tokens will be consumed, and the number of tokens in the token bucket will decrease.
[0051] As an optional example, when the first quantity is less than the first threshold, the second forwarding strategy for forwarding the target access request to the target access interface includes:
[0052] Count the number of access requests that have been forwarded before the target access request is forwarded within the target time period;
[0053] If the number of already forwarded access requests is greater than or equal to the second threshold, the target access request will be forwarded to the target access interface in the first time period after the target time period. The second threshold is the maximum number of access requests that can be forwarded within the target time period, and the first time period is the same as the target time period.
[0054] If the number of already forwarded access requests is less than the second threshold, the target access request will be forwarded to the target access interface within the target time period.
[0055] Optionally, in this embodiment, if the second forwarding strategy is used to forward the target access request, the number of access requests that have been forwarded (excluding the target access request) within the target time period can be counted. If this number is greater than or equal to the second threshold, it indicates that the number of access requests forwarded within the target time period has reached its limit, and forwarding can no longer continue within the target time period. Therefore, the target access request waits and is not forwarded temporarily. The target access request is then forwarded again in the first time period following the target time period. The second threshold can be the same or different for each time period. If the number of access request forwards within a time period reaches the second threshold, no more access requests are forwarded within that time period, and the remaining unforwarded access requests wait until the next time period for forwarding. For example, as... Figure 4 As shown, Figure 4 The time period includes different time periods, such as time period 402 and time period 404. Time period 404 allows 2 access requests to be sent. However, access requests 1 to 3 are received. Therefore, according to the order of receipt, access request 3 will wait until time period 404 before being forwarded.
[0056] As an optional example, the above method also includes:
[0057] When forwarding a target access request using the first forwarding strategy, if the first number changes from being greater than or equal to the first threshold to being less than the first threshold, the forwarding strategy for the target access request is changed to the second forwarding strategy.
[0058] When forwarding a target access request using the second forwarding strategy, if the first number changes from being less than the first threshold to being greater than or equal to the first threshold, the strategy is changed from using the second forwarding strategy to using the first forwarding strategy.
[0059] Optionally, in this embodiment, the use of a first forwarding strategy and a second forwarding strategy to forward access requests can be flexibly switched. This can be determined based on a first number of access requests received within a target time period. If the first number is greater than or equal to a first threshold, the first forwarding strategy is used; if the first number is less than the first threshold, the second forwarding strategy is used. When switching forwarding strategies, the currently forwarded access request is first sent using the original forwarding strategy, and the next access request is sent using the changed forwarding strategy.
[0060] As an optional example, when a target access request for accessing the target storage object is obtained, the access control parameters for the target storage object include:
[0061] When the target access request is to perform a read operation on the target storage object, the access control parameters configured for the target storage object are obtained. The access control parameters are used to control the number of access requests to read the target storage object per unit time.
[0062] When the target access request is to perform a write operation on the target storage object, the access control parameters configured for the target storage object are obtained. The access control parameters are used to control the number of access requests that request to write data to the target storage object per unit time.
[0063] When the target access request is to perform read and write operations on the target storage object, the access control parameters configured for the target storage object are obtained. The access control parameters are used to control the number of access requests that request to perform read and write operations on the target storage object per unit time.
[0064] Optionally, in this embodiment, not only can each storage object be configured with the same or different access control parameters, but different access control parameters can also be configured for the same storage object. For example, for the same storage object, access control parameters for read operations, access control parameters for write operations, and access control parameters for both read and write operations can be configured. The access control parameters for read operations constrain the number of read access requests. For example, if the access control parameter for read operations is 100 and the access control parameter for write operations is 50, if the number of access requests for reading operations on the target storage object exceeds 100, the excess access requests can be temporarily not forwarded to the target access interface. However, if the number of access requests for write operations on the target storage object is less than 50, the write access requests can be forwarded to the target access interface.
[0065] As an optional example, the above method also includes:
[0066] Determine the memory space occupied by the target access request and other access requests;
[0067] When the occupied space reaches the maximum memory capacity, upon receiving a new access request, the new access request will be directly forwarded to the corresponding access interface.
[0068] Optionally, in this embodiment, for a target access request, the memory space occupied by the target access request and other access requests can be viewed. A target storage object may correspond to multiple access requests. The amount of memory space occupied by each storage object's access request is calculated. If the memory space occupied by multiple access requests for storage objects exceeds the maximum memory capacity, any new access request for the storage object can be directly forwarded to the corresponding access interface since the memory can no longer accommodate it.
[0069] Optionally, combined Figure 5 S502 to S508 will be described below. In this embodiment, the user's target access request arrives at the proxy server nginx. nginx receives the request, and the Limiter of nginx's Lua module processes it according to hotspot control rules. The hotspot control rules can be different for different target storage objects. For example, target storage object 1 can be configured with access control parameters of 100 for read operations, 50 for write operations, and 100 for both read and write operations. The Limiter parses the rules, executes the rate limiting algorithm, and if the number of access requests received within a unit of time does not exceed the threshold, the target access request is allowed and forwarded to the access control interface (Application Programming Interface, API). If the threshold is exceeded, the target access request is rejected and a status code of 429 is returned.
[0070] In this embodiment, either the token bucket algorithm or the fixed window algorithm can be used when performing rate limiting. The two algorithms can be flexibly switched. A first threshold can be configured, for example, 1. If the first number of requests within the target time period is greater than or equal to 1, the token bucket algorithm is used; if the first number is less than 1, the fixed window algorithm is used. After nginx receives a request, the Limiter takes over request processing. The Limiter parses the request, obtaining which storage object (bucket, object) the target access request is accessing and whether the request type is a read operation, a write operation, or a read-write operation. The Limiter parses the rate limiting rules and executes the corresponding algorithm according to the rules. When the token bucket limit in the rule is <1 / s (one request per second), it automatically switches to the fixed window, converted by the formula round(1 / n), meaning one request is sent every n seconds (1 / n requests per second).
[0071] The following is a hotspot rule configuration in this embodiment, where the key is separated by the @ symbol in the format: <bucket>@<UPLOAD|DONWLOAD|ALL> @ALL, where value is the threshold.
[0072] Example:
[0073] The maximum hotspot for all read requests is 100 QPS.
[0074] {"@DONWLOAD@ALL":100}
[0075] The maximum hotspot for all write requests is 100 QPS.
[0076] {"@UPLOAD@ALL":100}
[0077] A Bucke read / write request hotspot can reach a maximum of 100 QPS:
[0078] {"A@ALL@ALL":100}
[0079] In this embodiment, the resources required by the Limiter are the number of times each object is accessed, which needs to be stored in memory.
[0080] Memory size (bytes) allocation formula: L*Q*N*B
[0081] L: Length of the object key hash value (SHA1), which is 40.
[0082] Q: Requests per second
[0083] N: Number of algorithm storage requests saved for N seconds
[0084] B: Reserved buffer coefficient
[0085] For example: 40 * 10000 * 5 * 1.5 (bytes). If the required memory space exceeds the maximum memory capacity, the new access request can be sent directly to the access interface.
[0086] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that the present invention is not limited to the described order of actions, because according to the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to the present invention.
[0087] According to another aspect of the embodiments of this application, an access request processing apparatus is also provided, such as... Figure 6 As shown, it includes:
[0088] The acquisition module 602 is used to acquire access control parameters of the target storage object when a target access request for accessing the target storage object is acquired. The access control parameters are used to control the number of access requests to access the target storage object per unit time.
[0089] The processing module 604 is used to reject the target access request from accessing the target storage object when the total number of the target access request and other access requests to access the target storage object within a unit time exceeds the access control parameter. The other access requests are requests to access the target storage object received before the target access request.
[0090] The first forwarding module 606 is used to forward the target access request to the target access interface of the target storage object when the total number of the target access request and other access requests is less than or equal to the access control parameter, so that the target account that sent the target access request can access the target storage object.
[0091] Optionally, the storage object in this embodiment can be an object stored on a server for providing services. The services provided by the storage object can be invoked by calling its access interface.
[0092] In this embodiment, the access control parameters can be parameters pre-configured for each storage object. The access control parameters for different storage objects can be the same or different.
[0093] In this embodiment, the access control parameters constrain the number of access requests to the target storage object within a unit of time. If the number of other access requests to the target storage object within a unit of time reaches the access control parameters, then after receiving the target access request, the total number of the target access request and other access requests exceeds the access control parameters, and the target access request will not be forwarded to the target access interface of the target storage object. If the number of other access requests does not reach the access control parameters, then after receiving the target access request, the total number of the target access request and other access requests does not exceed the access control parameters. In this case, the target access request can be forwarded to the target access interface for access.
[0094] Optionally, the unit time in this embodiment can be a preset time. By setting the unit time and access control parameters, the maximum number of access requests to a certain storage object within a certain time period can be determined.
[0095] In this embodiment, the above-described method for processing access requests can be applied to a proxy server. For example, as... Figure 2 As shown in Figure 2, the proxy server is responsible for forwarding access requests to the access interface. Different access requests are sent to the proxy server, which then forwards the access requests to the access interface of the storage object requested by the access request.
[0096] Through this embodiment and the above method, when an access request to access the target storage object is received, it can be checked whether the total number of access requests to the target storage object exceeds the limit. If the limit is exceeded, access to the target storage object is rejected, thereby realizing access control of the target storage object and avoiding a situation where a large number of access requests to the storage object in a short period of time cause the storage object to be unable to provide stable services.
[0097] As an optional example, the first forwarding module described above includes:
[0098] The first forwarding unit is used to forward the target access request to the target access interface by adopting a first forwarding strategy when the first number of the target access request and other access requests received within the target time period of receiving the target access request is greater than or equal to a first threshold.
[0099] The second forwarding unit is used to forward the target access request to the target access interface using a second forwarding strategy when the first number is less than the first threshold.
[0100] Optionally, in this embodiment, if the target access request can be forwarded to the target access interface, different forwarding strategies can be used to control the forwarding of the target access request. This embodiment can use the total number of access requests received within a target time period to determine the forwarding strategy for the target access request. The target time period can be the same as or different from the unit time period. The system counts whether the number of access requests received within the target time period is greater than a first threshold. If it is greater than the first threshold, the first forwarding strategy is adopted; if the number of access requests is less than the first threshold, the second forwarding strategy is adopted.
[0101] In this embodiment, the first threshold can be a pre-configured value, and the forwarding frequency of the first forwarding strategy and the second forwarding strategy are different.
[0102] As an optional example, the first forwarding unit described above includes:
[0103] The acquisition subunit is used to acquire one or more tokens from the token bucket, wherein tokens are generated in the token bucket at a predetermined frequency, the generated tokens are stored in the token bucket, and the tokens are used to transmit the access request to the corresponding access interface.
[0104] The first determining subunit is used to determine one or more acquired tokens as the target token;
[0105] The first forwarding subunit is used to forward the target access request to the target access interface using the target token.
[0106] Optionally, in this embodiment, the token bucket is a storage area for producing and storing tokens. The token bucket produces tokens at a predetermined frequency, and after production, the tokens are stored in the token bucket. Therefore, the token bucket contains tokens. When forwarding a target access request to the target access interface, the target token is retrieved from the token bucket for forwarding the target access request. Forwarding the target access request may use one or more tokens; therefore, the number of tokens required is determined by retrieving the appropriate number from the token bucket for forwarding. Once a token is retrieved from the token bucket, it is used and no longer stored in the token bucket. For example, as... Figure 3 As shown, Figure 3 In the token bucket 302, tokens 304 are included, and new tokens 304 are generated at a predetermined frequency and stored in the token bucket 302. When forwarding a target access request, token 304 is obtained from the token bucket 302 and the target access request is forwarded to the target access interface.
[0107] As an optional example, the first forwarding unit described above also includes:
[0108] The processing subunit is used to wait for the token bucket to generate new tokens when the number of tokens in the token bucket is less than the number of tokens for the target token.
[0109] The second determining subunit is used to use the tokens in the token bucket as the target token when the number of tokens in the token bucket is equal to the number of tokens in the target token.
[0110] Optionally, in this embodiment, the tokens in the token bucket may not be sufficient for forwarding the target access request. If there are not enough tokens in the token bucket, the target access request will not be forwarded temporarily. Instead, the system will wait for tokens to be generated in the token bucket. Once there are enough tokens to forward the target access request, the tokens in the token bucket will be used as the target tokens to forward the target access request. The target tokens will be consumed, and the number of tokens in the token bucket will decrease.
[0111] As an optional example, the second forwarding unit described above includes:
[0112] The statistics sub-unit is used to count the number of access requests that have been forwarded before the target access request is forwarded within the target time period.
[0113] The second forwarding subunit is used to forward the target access request to the target access interface in the first time period after the target time period if the number of already forwarded access requests is greater than or equal to the second threshold. The second threshold is the maximum number of access requests that can be forwarded within the target time period, and the first time period is the same as the duration of the target time period.
[0114] The third forwarding subunit is used to forward the target access request to the target access interface within the target time period if the number of already forwarded access requests is less than the second threshold.
[0115] Optionally, in this embodiment, if the second forwarding strategy is used to forward the target access request, the number of access requests that have been forwarded (excluding the target access request) within the target time period can be counted. If this number is greater than or equal to the second threshold, it indicates that the number of access requests forwarded within the target time period has reached its limit, and forwarding can no longer continue within the target time period. Therefore, the target access request waits and is not forwarded temporarily. The target access request is then forwarded again in the first time period following the target time period. The second threshold can be the same or different for each time period. If the number of access request forwards within a time period reaches the second threshold, no more access requests are forwarded within that time period, and the remaining unforwarded access requests wait until the next time period for forwarding. For example, as... Figure 4 As shown, Figure 4 The time period includes different time periods, such as time period 402 and time period 404. Time period 404 allows 2 access requests to be sent. However, access requests 1 to 3 are received. Therefore, according to the order of receipt, access request 3 will wait until time period 404 before being forwarded.
[0116] As an optional example, the first forwarding module described above also includes:
[0117] The first adjustment unit is configured to, when forwarding a target access request using the first forwarding strategy, adjust the forwarding of the target access request to the second forwarding strategy when the first number changes from being greater than or equal to the first threshold to being less than the first threshold.
[0118] The second adjustment unit is used to adjust the forwarding of the target access request from the second forwarding strategy to the first forwarding strategy when the first number changes from less than the first threshold to greater than or equal to the first threshold.
[0119] Optionally, in this embodiment, the use of a first forwarding strategy and a second forwarding strategy to forward access requests can be flexibly switched. This can be determined based on a first number of access requests received within a target time period. If the first number is greater than or equal to a first threshold, the first forwarding strategy is used; if the first number is less than the first threshold, the second forwarding strategy is used. When switching forwarding strategies, the currently forwarded access request is first sent using the original forwarding strategy, and the next access request is sent using the changed forwarding strategy.
[0120] As an optional example, the above acquisition module includes:
[0121] The first acquisition unit is used to acquire access control parameters configured for the target storage object when the target access request is to perform a read operation on the target storage object. The access control parameters are used to control the number of access requests to read the target storage object per unit time.
[0122] The second acquisition unit is used to acquire the access control parameters configured for the target storage object when the target access request is to perform a write operation on the target storage object. The access control parameters are used to control the number of access requests that request to write data to the target storage object per unit time.
[0123] The third acquisition unit is used to acquire the access control parameters configured for the target storage object when the target access request is to perform read and write operations on the target storage object. The access control parameters are used to control the number of access requests that request to perform read and write operations on the target storage object per unit time.
[0124] Optionally, in this embodiment, not only can each storage object be configured with the same or different access control parameters, but different access control parameters can also be configured for the same storage object. For example, for the same storage object, access control parameters for read operations, access control parameters for write operations, and access control parameters for both read and write operations can be configured. The access control parameters for read operations constrain the number of read access requests. For example, if the access control parameter for read operations is 100 and the access control parameter for write operations is 50, if the number of access requests for reading operations on the target storage object exceeds 100, the excess access requests can be temporarily not forwarded to the target access interface. However, if the number of access requests for write operations on the target storage object is less than 50, the write access requests can be forwarded to the target access interface.
[0125] As an optional example, the above-described apparatus further includes:
[0126] The determination module is used to determine the memory space occupied by the target access request and other access requests;
[0127] The second forwarding module is used to forward new access requests directly to the corresponding access interface when the memory capacity is reached, provided that the occupied space has been reached.
[0128] Optionally, in this embodiment, for a target access request, the memory space occupied by the target access request and other access requests can be viewed. A target storage object may correspond to multiple access requests. The amount of memory space occupied by each storage object's access request is calculated. If the memory space occupied by multiple access requests for storage objects exceeds the maximum memory capacity, any new access request for the storage object can be directly forwarded to the corresponding access interface since the memory can no longer accommodate it.
[0129] For other examples of this embodiment, please refer to the examples above, which will not be repeated here.
[0130] Figure 7 This is a structural block diagram of an optional electronic device according to an embodiment of this application, such as... Figure 7 As shown, it includes a processor 702, a communication interface 704, a memory 706, and a communication bus 708. The processor 702, communication interface 704, and memory 706 communicate with each other via the communication bus 708.
[0131] Memory 706 is used to store computer programs;
[0132] When processor 702 executes a computer program stored in memory 706, it performs the following steps:
[0133] If a target access request for accessing the target storage object is obtained, the access control parameters of the target storage object are obtained, wherein the access control parameters are used to control the number of access requests to access the target storage object per unit time.
[0134] If the total number of the target access request and other access requests to access the target storage object within a unit of time exceeds the access control parameter, the target access request is denied access to the target storage object. The other access requests are those received before the target access request for accessing the target storage object.
[0135] If the total number of target access requests and other access requests is less than or equal to the access control parameters, the target access request is forwarded to the target access interface of the target storage object so that the target account that sent the target access request can access the target storage object.
[0136] Optionally, in this embodiment, the communication bus can be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7 The symbol is represented by a single thick line, but this does not indicate that there is only one bus or one type of bus. The communication interface is used for communication between the aforementioned electronic devices and other devices.
[0137] The memory may include RAM, or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0138] As an example, the memory 706 described above may include, but is not limited to, the acquisition module 602, the processing module 604, and the first forwarding module 606 in the aforementioned request processing device. Furthermore, it may include, but is not limited to, other module units in the aforementioned request processing device, which will not be elaborated upon in this example.
[0139] The processors mentioned above can be general-purpose processors, including but not limited to: CPU (Central Processing Unit), NP (Network Processor), etc.; they can also be DSP (Digital Signal Processor), ASIC (Application Specific Integrated Circuit), FPGA (Field-Programmable Gate Array), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0140] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments, and will not be repeated here.
[0141] Those skilled in the art will understand that Figure 7 The structure shown is for illustrative purposes only. The device that implements the above request processing method can be a terminal device, such as a smartphone (e.g., Android phone, iOS phone), tablet computer, PDA, mobile Internet Device (MID), PAD, etc. Figure 7 This does not limit the structure of the aforementioned electronic devices. For example, the electronic device may also include components that are more... Figure 7 The more or fewer components shown (such as network interfaces, display devices, etc.), or having the same Figure 7 The different configurations shown.
[0142] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, ROM, RAM, disk or optical disk, etc.
[0143] According to another aspect of the present invention, a computer-readable storage medium is also provided, wherein a computer program is stored therein, wherein the computer program is executed by a processor to perform the steps in the above-described access request processing method.
[0144] Optionally, in this embodiment, those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0145] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0146] If the integrated units in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in the aforementioned computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention.
[0147] In the above embodiments of the present invention, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0148] In the several embodiments provided in this application, it should be understood that the disclosed client can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, indirect coupling or communication connection between units or modules, and may be electrical or other forms.
[0149] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0150] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0151] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.< / bucket>
Claims
1. A processing method of an access request, characterized by, include: Upon receiving a target access request for accessing a target storage object, the access control parameters of the target storage object are obtained, wherein the access control parameters are used to control the number of access requests to access the target storage object per unit time. If the total number of the target access request and other access requests to the target storage object within the unit time exceeds the access control parameter, the target access request is denied access to the target storage object, wherein the other access requests are requests to access the target storage object received before the target access request; If the total number of the target access request and the other access requests is less than or equal to the access control parameter, the target access request is forwarded to the target access interface of the target storage object so that the target account that sent the target access request can access the target storage object. Wherein, forwarding the target access request to the target access interface of the target storage object when the total number of the target access request and other access requests currently accessing the target storage object is less than or equal to the access control parameter includes: when the first number of the target access request and other access requests received within a target time period of receiving the target access request is greater than or equal to a first threshold, forwarding the target access request to the target access interface using a first forwarding strategy; and when the first number is less than the first threshold, forwarding the target access request to the target access interface using a second forwarding strategy. The method of forwarding the target access request to the target access interface using the first forwarding strategy includes: obtaining one or more tokens from a token bucket, wherein the token bucket generates tokens at a predetermined frequency and stores the generated tokens in the token bucket, and the tokens are used to transmit the access request to the corresponding access interface; determining one or more of the obtained tokens as target tokens; and using the target tokens to forward the target access request to the target access interface. The second forwarding strategy for forwarding the target access request to the target access interface includes: counting the number of access requests that have been forwarded before the target access request is forwarded within the target time period; if the number of already forwarded access requests is greater than or equal to a second threshold, forwarding the target access request to the target access interface within a first time period after the target time period, wherein the second threshold is the maximum number of access requests allowed to be forwarded within the target time period, and the first time period is equal in length to the target time period; if the number of already forwarded access requests is less than the second threshold, forwarding the target access request to the target access interface within the target time period.
2. The method of claim 1, wherein, The method further includes: If the number of tokens in the token bucket is less than the number of tokens for the target token, wait for the token bucket to generate new tokens; If the number of tokens in the token bucket is equal to the number of tokens in the target token, then the tokens in the token bucket are used as the target token.
3. The method of claim 1, wherein, The method further includes: When forwarding the target access request using the first forwarding strategy, if the first number changes from being greater than or equal to the first threshold to being less than the first threshold, the forwarding of the target access request is changed from using the first forwarding strategy to using the second forwarding strategy. When forwarding the target access request using the second forwarding strategy, if the first quantity changes from being less than the first threshold to being greater than or equal to the first threshold, the method of forwarding the target access request using the second forwarding strategy is adjusted to forwarding the target access request using the first forwarding strategy.
4. The method of claim 1, wherein, When a target access request for accessing a target storage object is received, obtaining the access control parameters of the target storage object includes: When the target access request is to perform a read operation on the target storage object, the access control parameters configured for the target storage object are obtained, wherein the access control parameters are used to control the number of access requests to read the target storage object per unit time. When the target access request is to perform a write operation on the target storage object, the access control parameters configured for the target storage object are obtained, wherein the access control parameters are used to control the number of access requests that request to write data to the target storage object per unit time. When the target access request is to perform read and write operations on the target storage object, the access control parameters configured for the target storage object are obtained, wherein the access control parameters are used to control the number of access requests that request to perform read and write operations on the target storage object per unit time.
5. The method of claim 1, wherein, The method further includes: Determine the memory space occupied by the target access request and the other access requests; When the occupied space reaches the maximum capacity of the memory, upon receiving a new access request, the new access request will be directly forwarded to the corresponding access interface.
6. An apparatus for processing an access request, characterized by comprising: include: The acquisition module is used to acquire access control parameters of the target storage object when a target access request for accessing the target storage object is acquired, wherein the access control parameters are used to control the number of access requests to access the target storage object per unit time. The processing module is configured to reject the target access request from accessing the target storage object if the total number of the target access request and other access requests to access the target storage object within the unit time exceeds the access control parameter, wherein the other access requests are requests to access the target storage object received before the target access request. The first forwarding module is used to forward the target access request to the target access interface of the target storage object when the total number of the target access request and the other access requests is less than or equal to the access control parameter, so that the target account that sent the target access request can access the target storage object. Wherein, forwarding the target access request to the target access interface of the target storage object when the total number of the target access request and other access requests currently accessing the target storage object is less than or equal to the access control parameter includes: when the first number of the target access request and other access requests received within a target time period of receiving the target access request is greater than or equal to a first threshold, forwarding the target access request to the target access interface using a first forwarding strategy; and when the first number is less than the first threshold, forwarding the target access request to the target access interface using a second forwarding strategy. The method of forwarding the target access request to the target access interface using the first forwarding strategy includes: obtaining one or more tokens from a token bucket, wherein the token bucket generates tokens at a predetermined frequency and stores the generated tokens in the token bucket, and the tokens are used to transmit the access request to the corresponding access interface; determining one or more of the obtained tokens as target tokens; and using the target tokens to forward the target access request to the target access interface. The second forwarding strategy for forwarding the target access request to the target access interface includes: counting the number of access requests that have been forwarded before the target access request is forwarded within the target time period; if the number of already forwarded access requests is greater than or equal to a second threshold, forwarding the target access request to the target access interface within a first time period after the target time period, wherein the second threshold is the maximum number of access requests allowed to be forwarded within the target time period, and the first time period is equal in length to the target time period; if the number of already forwarded access requests is less than the second threshold, forwarding the target access request to the target access interface within the target time period.
7. A computer-readable storage medium storing a computer program, the computer-readable storage medium being characterized by, The computer program is executed by the processor to perform the method described in any one of claims 1 to 5.
8. An electronic device comprising a memory and a processor, characterized in that The memory stores a computer program, and the processor is configured to execute the method described in any one of claims 1 to 5 through the computer program.