Frequency control method, system and device and storage medium
By obtaining the resource identifier and frequency control dimension value of the target interface, searching and executing refined frequency control configuration, the problem of low frequency control quality in the existing technology is solved, and precise control of the target interface and higher-quality frequency control strategies are achieved.
Patent Information
- Application Number
- CN202410370597.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-28
- Publication Date
- 2025-09-30
AI Technical Summary
Existing service frequency control and business frequency control methods cannot meet the increasingly complex business needs, resulting in low frequency control quality and the inability to implement refined frequency control strategies.
By receiving the service request, the first frequency control configuration under the resource identifier of the target interface is obtained, the dimension value is obtained according to the frequency control dimension, the second frequency control configuration that matches the dimension value is found, and the frequency control operation is performed on the target interface according to the second frequency control configuration to implement a refined frequency control strategy.
The precision and quality of frequency control are improved, which can meet more frequency control requirements and achieve precise control of the target interface.
Smart Images

Figure CN120729798A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a frequency control method, system, device, and storage medium. Background Art
[0002] In some technologies, frequency control is mainly divided into service frequency control and business frequency control. Among them, service frequency control formulates frequency control strategies based on static parameters (such as interface name, URL). For example, a first threshold is set for an interface A. After the number of times interface A is called exceeds the first threshold, the call request to interface A is rejected within the first target time (such as 10 minutes). Business frequency control formulates frequency control strategies based on dynamic variable parameters (such as UID, IP, Cookie value). For example, a second threshold is set for the number of times a single UID calls interface A. After the number of times a UID1 calls interface A exceeds the second threshold, the call request initiated by UID1 to interface A is rejected within the second target time (such as 5 minutes). Generally, service frequency control can protect services and interfaces to prevent sudden large traffic requests from impacting the system, thereby causing the system to avalanche and unable to continue to provide services to the outside world; while business frequency control can block malicious requests by limiting the frequency with which users access certain resources.
[0003] However, as the business becomes more and more complex, relying solely on service frequency control and business frequency control can no longer meet actual business needs, and the frequency control quality is not high.
[0004] In view of this, a method for improving frequency control quality is urgently needed. Summary of the Invention
[0005] In view of this, embodiments of the present disclosure provide a frequency control method, a frequency control system, an electronic device, and a computer-readable storage medium, which can improve the quality of frequency control.
[0006] In one aspect, the present disclosure provides a frequency control method, the method comprising:
[0007] receiving a service request, wherein the service request includes a target interface to be called;
[0008] In response to a resource identifier associated with the target interface, obtaining a first frequency control configuration under the resource identifier, wherein the first frequency control configuration includes a frequency control dimension;
[0009] Obtaining a dimension value corresponding to the frequency control dimension of the service request, and using the resource identifier and the dimension value as a search index to search for a second frequency control configuration matching the search index;
[0010] In response to finding the second frequency control configuration, a frequency control operation is performed on the target interface according to the first frequency control logic included in the second frequency control configuration.
[0011] In one aspect, the present disclosure provides a frequency control system, the system comprising:
[0012] A request receiving module, configured to receive a service request, wherein the service request includes a target interface to be called;
[0013] A first configuration acquisition module, configured to acquire, in response to a resource identifier associated with the target interface, a first frequency control configuration under the resource identifier, wherein the first frequency control configuration includes a frequency control dimension;
[0014] A second configuration acquisition module is configured to obtain a dimension value corresponding to the frequency control dimension of the service request, and use the resource identifier and the dimension value as a search index to search for a second frequency control configuration matching the search index;
[0015] The frequency control operation module is configured to, in response to finding the second frequency control configuration, perform a frequency control operation on the target interface according to the first frequency control logic included in the second frequency control configuration.
[0016] On the other hand, the present disclosure further provides a computer-readable storage medium, which is used to store a computer program. When the computer program is executed by a processor, the method described above is implemented.
[0017] On the other hand, the present disclosure further provides an electronic device, which includes a processor and a memory, wherein the memory is used to store a computer program, and when the computer program is executed by the processor, the method described above is implemented.
[0018] In the technical solutions of some embodiments of the present disclosure, the dimension value corresponding to the frequency control dimension of the service request can be obtained through the frequency control dimension set in the first frequency control configuration. According to the dimension value, a second frequency control configuration that matches the dimension value can be further found, and then the frequency control operation can be performed on the target interface according to the second frequency control configuration. Since the second frequency control configuration is subdivided according to different dimension values under the frequency control dimension, when the dimension values corresponding to the service request are different, the frequency control operation can be performed on the target interface called by the service request according to different frequency control strategies. In this way, the frequency control for the target interface is more refined, and more frequency control requirements can be met, thereby improving the quality of frequency control. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The features and advantages of the present disclosure will be more clearly understood by referring to the accompanying drawings, which are schematic and should not be construed as limiting the present disclosure in any way. In the accompanying drawings:
[0020] Figure 1 A schematic diagram of a frequency control method provided by an embodiment of the present disclosure is shown;
[0021] Figure 2 A schematic diagram showing the relationship between a first frequency control configuration and a second frequency control configuration provided by an embodiment of the present disclosure is shown;
[0022] Figure 3 A schematic diagram showing the relationship between a first frequency control configuration and a second frequency control configuration provided by another embodiment of the present disclosure is shown;
[0023] Figure 4 A flow diagram of a service request in a hardware device provided by an embodiment of the present disclosure is shown;
[0024] Figure 5 A schematic diagram showing the relationship between a first frequency control configuration and a second frequency control configuration provided by another embodiment of the present disclosure is shown;
[0025] Figure 6 An interactive schematic diagram of a frequency control method provided by an embodiment of the present disclosure is shown;
[0026] Figure 7 A module diagram of a frequency control system provided by an embodiment of the present disclosure is shown;
[0027] Figure 8 A schematic diagram of an electronic device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0028] To make the purpose, technical solutions, and advantages of the embodiments of the present disclosure more clear, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making any creative efforts shall fall within the scope of protection of the present disclosure.
[0029] As services develop, more and more sophisticated frequency control requirements have emerged. The following are some examples of frequency control requirements:
[0030] 1) Abnormally time-consuming request circuit breaker.
[0031] This frequency control requirement refers to when calling an interface to query a specified number of data items, if the following situation occurs a preset number of times (for example, 5 times) within a first preset time (for example, 5 minutes):
[0032] The specified number of entries exceeds the entry threshold, and the query time exceeds the time threshold (for example, 10 seconds).
[0033] Then, within a second preset time (eg, 10 minutes), the call to the interface is cut off.
[0034] For example, when calling interface A to query a video, if the following situation occurs 8 times within 5 minutes:
[0035] In the request to call interface A, the number of videos specified for query exceeds 1,000, and the video query time of the request exceeds 10 seconds.
[0036] Then, in the next 10 minutes, call requests to interface A will be rejected.
[0037] 2) Multiple versions of interfaces share the same frequency control threshold.
[0038] This frequency control requirement means that when a function corresponds to multiple versions of interfaces, a frequency control threshold is set for the function, and if the sum of the number of calls to the multiple versions of the interface reaches the frequency control threshold within a third preset time (for example, 1 minute), the call requests for the multiple versions of the interface will be rejected within a fourth preset time (for example, 3 minutes).
[0039] For example, consider the product attribute editing feature. Assume a frequency control threshold of 1000 is set for this feature, and assume the interfaces used to implement this feature include interface A1 (version 1), interface A2 (version 2), and interface A3 (version 3). If the total number of calls to interfaces A1, A2, and A3 reaches 1000 within one minute, then calls to interfaces A1, A2, and A3 can be rejected for the next three minutes.
[0040] 3) Frequency control is performed based on the batch request quantity in the interface call request.
[0041] The batch request size refers to the amount of data that needs to be processed in a batch during a single API call. For example, if a request to API A specifies a query for 1,000 videos, the 1,000 here is the batch request size.
[0042] In this frequency control requirement, the batch request volume in multiple call requests for the same interface can be accumulated. If the accumulated batch request volume exceeds the request volume threshold within the fifth preset time (for example, 3 minutes), the call request for the interface can be rejected within the sixth preset time (for example, 7 minutes). For example, assuming that the request volume threshold is 120, and assuming that within 3 minutes, there are 4 call requests for interface A, and in these 4 call requests for interface A, the batch request volumes are 25, 40, 50, and 20 respectively. After accumulating the batch request volumes in the 4 call requests for interface A, the result is 135, which exceeds the request volume threshold, so the call request for interface A can be rejected within 7 minutes.
[0043] 4) Frequency control is performed when specified parameters are passed in the interface call request.
[0044] For example, in a business scenario where interface A is called to modify a field, it is assumed that the fields can be divided into core fields and non-core fields. When modifying a core field, the call to interface A is counted, and when modifying a non-core field, the call to interface A is not counted. If the call count for interface A reaches the first counting threshold within the seventh preset time period (for example, 1 day), the request to call interface A to modify the core field can be rejected within the eighth preset time period (for example, half a day). In this way, requests to modify non-core fields can be prevented from exhausting the number of times interface A is allowed to be called.
[0045] 5) Frequency control is performed when the specified parameter in the interface call request is the specified value.
[0046] For example, in a call request for interface A, calls to interface A are counted only when parameter 1 in the call request is "enable." If the call count for interface A reaches the second counting threshold within a ninth preset time period (e.g., three days), call requests for interface A with parameter 1 being "enable" may be rejected within a tenth preset time period (e.g., 10 days).
[0047] Based on the frequency control requirements listed in 1) to 5) above, it is understandable that as services develop, it is foreseeable that there will be more and more refined frequency control requirements. However, based on the existing service frequency control and business frequency control, these refined frequency control requirements cannot be met, resulting in low frequency control quality. In view of this, the present disclosure provides a refined frequency control method that can solve the problems encountered in current frequency control and improve frequency control quality. The frequency control method can be applied to electronic devices. Electronic devices include but are not limited to laptops, desktop computers, tablet computers, servers, etc.
[0048] See also Figure 1 , which is a schematic diagram of a frequency control method provided in one embodiment of the present disclosure. Figure 1 The frequency control method includes the following steps:
[0049] Step S11: receiving a service request, where the service request includes a target interface to be called.
[0050] Specifically, a business request can represent a request to implement one or more functions (such as creating a status update, obtaining video information, and downloading a video). Each function can correspond to one or more interfaces. The business request specifies the function to be implemented by specifying the interface to be called. For example, suppose the function of creating a status update corresponds to interface A and interface B, and the function of obtaining video information corresponds to interface C. When the business request includes interface A, it means that interface A needs to be called to create a status update; when the business request includes interface C, it means that interface C needs to be called to obtain video information.
[0051] Typically, a service request may also include parameters required for the interface call. For example, when calling interface C to obtain video information, the service request may include a video ID, indicating that the video information of the target video identified by the video ID is to be obtained.
[0052] Step S12: In response to the target interface having an associated resource identifier, a first frequency control configuration under the resource identifier is acquired, wherein the first frequency control configuration includes a frequency control dimension.
[0053] In this embodiment, a first frequency control configuration can be pre-created for the corresponding function based on the target interface's intended function. The first frequency control configuration can also be referred to as a default frequency control configuration, and the resource identifier is used to uniquely identify the first frequency control configuration. For example, if the target interface is used to implement the function of creating a status update, a first frequency control configuration A with a resource identifier of ABC can be pre-created for this function; if the target interface is used to implement the function of obtaining video information, a first frequency control configuration B with a resource identifier of ABC can be pre-created for this function.
[0054] For ease of description, it is assumed that the target interface is used to implement function A, and the resource identifier corresponding to the first frequency control configuration A of function A is resource identifier A. In this embodiment, some or all interfaces used to implement function A can be associated with resource identifier A. Among them, for interfaces associated with resource identifier A, it means that these interfaces need to perform frequency control operations according to the first frequency control configuration A; for interfaces not associated with resource identifier A, it means that these interfaces do not need to perform frequency control operations according to the first frequency control configuration A. For example, suppose that the interfaces used to implement function A include interface 1 of version V1, interface 2 of version V2, and interface 3 of version V3, wherein interface 1 and interface 2 are associated with resource identifier A, and interface 3 is not associated with resource identifier B. In this case, if the target interface is interface 1 or interface 2, it means that the frequency control operation needs to be performed according to the first frequency control configuration A; if the target interface is interface 3, it means that the frequency control operation does not need to be performed according to the first frequency control configuration A.
[0055] Furthermore, there are many ways to associate the interface with the resource identifier A. For example, the association relationship between the resource identifier A and the interface can be pre-created in a storage device such as a cache. For another example, the interface that needs to perform the frequency control operation can be configured in the first frequency control configuration A. In this case, after obtaining the target interface, the target first frequency control configuration where the target interface is located can be searched. If the target first frequency control configuration exists, then the resource identifier of the target first frequency control configuration is the resource identifier associated with the target interface; if the target first frequency control configuration does not exist, it means that there is no resource identifier associated with the target interface.
[0056] In response to the resource identifier associated with the target interface, the first frequency control configuration under the resource identifier can be obtained. The first frequency control configuration may include a frequency control dimension. Specifically, the frequency control dimension represents the dimensional division standard based on which the frequency control of the target interface is performed. In this embodiment, the frequency control dimension includes an interface dimension and an application dimension. From the interface dimension, it means that frequency control is performed on a single interface as a unit. When frequency control is performed on a single interface as a unit, the frequency control strategies for different interfaces may be different. That is, the target interface may have a corresponding frequency strategy. From the application dimension, it means that frequency control is performed on an application that calls the target interface as a unit. When frequency control is performed on an application that calls the target interface as a unit, the frequency control strategy for each application calling the target interface is different. In simple terms, according to one frequency control dimension, multiple categories can be obtained, the target interface may belong to one of the categories, and the frequency control strategies for different categories may be different. Different categories are obtained based on different frequency control dimensions.
[0057] It is understandable that the frequency control dimension division is not limited to the interface dimension and the application dimension, for example, it can also be divided from the client dimension that calls the target interface. The present disclosure does not limit the division of the frequency control dimension.
[0058] Step S13: Acquire the dimension value corresponding to the frequency control dimension of the service request, and use the resource identifier and the dimension value as a search index to search for a second frequency control configuration that matches the search index.
[0059] Specifically, the dimension value can represent the category identifier of the category to which the target interface called by the service request belongs, divided according to the frequency control dimension. For example, according to the interface dimension, the dimension value can be the interface identifier of the target interface; according to the application dimension, the dimension value can be the application ID that calls the target interface. The dimension values of different categories are different. When the dimension value changes with the change of the service request, the dimension value can be obtained from the service request. For example, from the application dimension, the application ID that calls the target interface changes with the change of the application that initiates the service request. In this case, the dimension value can be obtained from the service request. Correspondingly, if the dimension value does not change with the change of the service request, then the dimension value can be pre-configured in the first frequency control configuration, and then the dimension value can be obtained from the first frequency control configuration.
[0060] For different categories divided under a frequency control dimension, different second frequency control configurations can be set for the target interface according to different categories. The second frequency control configuration can include specific frequency control strategies for the target interface, such as frequency control thresholds. Since different categories correspond to different second frequency control configurations, more refined frequency control can be performed on the target interface. Taking the interface dimension and application dimension as an example:
[0061] From the interface perspective, you can set a second frequency control configuration for each interface. That is, a target interface can have a corresponding second frequency control configuration. In this case, frequency control operations can be performed on the target interface based on the corresponding second frequency control configuration.
[0062] From the application dimension, the second frequency control configuration can be set for the target interface based on the application category that calls the target interface. For example, in the second frequency control configuration corresponding to application 1, the frequency control threshold of target interface A can be set to 50 times, so that after target interface A is called 50 times by application 1 within 1 minute, the call request sent by application 1 to target interface A will be rejected within 3 minutes; and in the second frequency control configuration corresponding to application 2, the frequency control threshold of target interface A can be set to 1000 times, so that after target interface A is called 1000 times by application 2 within 1 minute, the call request sent by application 2 to target interface A will be rejected within 3 minutes.
[0063] In this embodiment, considering that different functions can have the same frequency control dimension division, the second frequency control configuration can be identified using the resource identifier in the first frequency control configuration and the dimension value obtained by the frequency control dimension division. Such an identifier can be unique. Accordingly, when searching for the second frequency control configuration for the target interface, the resource identifier associated with the target interface and the dimension value of the category to which the target interface belongs obtained by the frequency control maintenance division can be used as a search index to find the second frequency control configuration required for performing frequency control operations on the target interface.
[0064] In some other embodiments, the resource identifier, the frequency control dimension, and the dimension value obtained by dividing the frequency control dimension in the first frequency control configuration may also be used to identify the second frequency control configuration.
[0065] For easier understanding, please refer to Figure 2 , which is a schematic diagram of the relationship between the first frequency control configuration and the second frequency control configuration provided in an embodiment of the present disclosure. Figure 2 In the first frequency control configuration, the frequency control dimension is the application dimension. Assuming that there are n applications that call the target interface, then n second frequency control configurations can be obtained accordingly. Each second frequency control configuration corresponds to an application. Figure 2It can be seen that the frequency control thresholds are different in the second frequency control configurations corresponding to different applications. In this way, different frequency control can be performed on the target interface called by different applications based on different frequency control strategies. Furthermore, when searching for the target second frequency control configuration based on which the frequency control is performed on the target interface, the dimension value (such as the application ID) can be determined based on the application that sends the service request, and then the resource identifier, the determined dimension value, and the frequency control dimension are used as the search index to search for the second frequency control configuration that matches the search index. For example, assuming that the determined dimension value is C1, the resource identifier "XXXX", the frequency control dimension "application", and the dimension value "C1" are used as the search index, and it can be found that the second frequency control configuration 1 is the second frequency control configuration that matches the search index.
[0066] In this disclosure, the second frequency control configuration may also be referred to as a custom frequency control configuration.
[0067] Step S14: In response to finding the second frequency control configuration, a frequency control operation is performed on the target interface according to the first frequency control logic included in the second frequency control configuration.
[0068] Specifically, the frequency control operation includes frequency control of the target interface and non-frequency control of the target interface. The first frequency control logic is the logic in the second frequency control configuration for determining whether the target interface needs to be frequency controlled. In this embodiment, the first frequency control logic may include a frequency control condition. When the actual situation of calling the target interface reaches the frequency control condition, the target interface needs to be frequency controlled; when the actual situation of calling the target interface does not reach the frequency control condition, the target interface does not need to be frequency controlled. For example, the frequency control threshold can be used as a frequency control condition. When the number of times application C1 calls the target interface reaches the frequency control threshold, the target interface needs to be frequency controlled. In this case, the service request for calling the target interface can be rejected; when the number of times application C1 calls the target interface does not reach the frequency control threshold, the target interface does not need to be frequency controlled. In this case, the service request for calling the target interface can be executed.
[0069] In summary, in the technical solutions of some embodiments of the present disclosure, the dimension value corresponding to the frequency control dimension of the service request can be obtained through the frequency control dimension set in the first frequency control configuration. According to the dimension value, a second frequency control configuration that matches the dimension value can be further found, and then the frequency control operation can be performed on the target interface according to the second frequency control configuration. Since the second frequency control configuration is subdivided according to different dimension values under the frequency control dimension, when the dimension values corresponding to the service request are different, the frequency control operation can be performed on the target interface called by the service request according to different frequency control strategies. In this way, the frequency control for the target interface is more refined, and more frequency control requirements can be met, thereby improving the quality of frequency control.
[0070] The solution of the present disclosure is further described below.
[0071] In some embodiments, the first frequency control configuration may further include a second frequency control logic, and the method of the present disclosure may further include:
[0072] In response to not finding the second frequency control configuration, performing a frequency control operation on the service request according to the second frequency control logic.
[0073] For easier understanding, please refer to Figure 3 , is a schematic diagram of the relationship between the first frequency control configuration and the second frequency control configuration provided in another embodiment of the present disclosure. Figure 3 It includes two second frequency control configurations, namely, second frequency control configurations for application C1 and application C2, and, Figure 3 The first frequency control configuration includes a second frequency control logic. The second frequency control logic is similar to the first frequency control logic and will not be described in detail here. On this basis, it is assumed that the dimension value obtained is C3, that is, the application calling the target interface is C3. In this case, since there is no second frequency control configuration for application C3, the frequency control operation can be performed on the target interface based on the second frequency control logic in the first frequency control configuration. This principle can be understood as follows: the second frequency control logic in the first frequency control configuration is a candidate solution. When a second frequency control configuration matching the dimension value is found, a refined frequency control operation is performed on the target interface based on the second frequency control configuration; when a second frequency control configuration matching the dimension value is not found, a frequency control operation is performed on the target interface based on the second frequency control logic of the first frequency control configuration (that is, the candidate solution). In this way, the reliability of the solution is improved. At the same time, when there is no need to perform refined frequency control operations on the target interface based on each dimension value, the frequency control operation can be performed on the target interface in a relatively coarse manner, and the solution has better adaptability.
[0074] Furthermore, in some embodiments, in the first frequency control logic and the second frequency control logic, at least one frequency control logic includes a frequency control condition, and the frequency control condition includes a pre-frequency control condition. The above-mentioned frequency control operation on the service request according to the frequency control logic may include:
[0075] In response to the service request, before executing the service request, the pre-frequency control condition is met and the target interface is frequency controlled;
[0076] Before responding to the service request, the pre-frequency control condition is not met and the target interface is not frequency controlled.
[0077] Specifically, the pre-frequency control condition represents the conditions that the service request must meet before executing the service request. Figure 4 , which is a flow diagram of a business request in a hardware device provided by an embodiment of the present disclosure. Figure 4The hardware devices shown may include a login state gateway, an authority verification gateway, a front-end frequency control gateway, a rear-end frequency control gateway, and a business device that provides business services. Among them, the front-end frequency control gateway is located before the business device, and the rear-end frequency control gateway is located after the business device. The business device is used to execute the business request (i.e., complete the function of the target interface). The front-end frequency control conditions can be integrated into the front-end frequency control gateway. According to the arrow, after the business request passes through the login state gateway and the authority verification gateway, the business request can be pre-judged based on the front-end frequency control conditions in the front-end frequency control gateway. If the front-end frequency control conditions are met, frequency control can be performed on the target interface. In this case, the front-end frequency control gateway can intercept the business request without having to execute the business request through the business device; conversely, if the front-end frequency control conditions are not met, frequency control can be not performed on the target interface. In this case, the front-end frequency control gateway can not intercept the business request, and then execute the business request through the business device. For example, the pre-frequency control condition can be a frequency control threshold. If the number of calls to the target interface reaches the frequency control threshold, it means that the pre-frequency control condition is met, and the pre-frequency control gateway can intercept the service request without having to execute the service request through the service device. Conversely, if the number of calls to the target interface does not reach the frequency control threshold, it means that the pre-frequency control condition is not met, and the pre-frequency control gateway can not intercept the service request and execute the service request through the service device. In this way, service requests that meet the frequency control condition can be effectively intercepted with high reliability.
[0078] Furthermore, in some embodiments, for a service request including a target interface, it may be necessary to determine whether frequency control is required for the target interface when a service request is subsequently received based on the execution result of the processed service request. For example, taking the frequency control requirement of the above-mentioned abnormally time-consuming request fuse as an example, it is necessary to accumulate the number of times based on whether the query time of the processed service request exceeds the time threshold, and determine whether frequency control is required for the target interface in subsequent service requests based on the accumulated number of times. In view of this, in the above-mentioned first frequency control logic and the second frequency control logic, the frequency control conditions of at least one frequency control logic may also include post-frequency control conditions. Among them, the post-frequency control conditions represent the conditions that the execution result of the service request must meet after the service request is executed. The post-frequency control conditions can be set according to the actual frequency control requirements. Based on the post-frequency control conditions, the above-mentioned frequency control operation performed on the service request according to the frequency control logic may include:
[0079] In response to executing the service request, based on the execution result of the service request, the post-frequency control condition is met, and the frequency control values of the service requests are accumulated, where the frequency control value represents the number of service requests that meet the post-frequency control condition.
[0080] Specifically, the frequency control value is used to accumulate service requests whose execution results meet the post-frequency control conditions. Within the specified time period, if the frequency control value reaches the frequency control threshold, it means that the target interface in the service request needs to be frequency controlled. For example, in the frequency control requirement of the above-mentioned abnormally time-consuming request fuse, it is assumed that interface A needs to be called to perform a query operation. Then a frequency control value A can be set for the service request including interface A. Furthermore, in the service request including interface A, it is assumed that a service request 1 meets the pre-frequency control conditions, and after the service request 1 is processed by the service device, the execution time of the service request 1 can be determined based on the execution result of the service request 1. If the execution time of the service request 1 exceeds the time threshold, and the specified number of items in the service request 1 exceeds the number threshold, the frequency control value A is increased by 1. In this way, the service requests whose specified number exceeds the number threshold and the query time exceeds the time threshold are counted. Then, when a service request including interface A is subsequently received, it can be determined whether to perform frequency control on interface A based on the counting result.
[0081] Based on the execution result of the service request, after accumulating the frequency control value of the service request, more refined frequency control can be performed on the target interface based on the frequency control value.
[0082] Corresponding to the above frequency control value, in response to receiving a next service request including a target interface, the method of the present disclosure may further include:
[0083] In response to the frequency control value reaching the frequency control threshold, frequency control is performed on the target interface in the next service request.
[0084] For example, assume the frequency control threshold is 5. Within a specified time period (e.g., 5 minutes), if the frequency control value corresponding to the next service request, including the service request of the target interface, reaches 5, the next service request needs to be intercepted, thus achieving fine-grained frequency control for the target interface.
[0085] In some embodiments, the frequency control condition includes a condition field, a matching field, and a target value field, where the matching field represents a matching method;
[0086] In response to satisfying the following conditions, it is determined that the frequency control condition is met:
[0087] According to the matching method represented by the matching field, the value of the condition field is matched with the value of the target value field.
[0088] For ease of understanding, an example of a first frequency control configuration is given below. It can be seen from the above description that the first frequency control configuration may include a second frequency control logic, and the second frequency control logic may include a frequency control condition.
[0089] "creative_update_status":{ / / resource identifier
[0090] "default_threshold":{ / / First frequency control configuration
[0091] "common_app":[{"duration_insec":10,"threshold":300}] / / Frequency control dimension is the application dimension
[0092] },
[0093] "path_mapping":{
[0094] " / creative / update / v1 / status / ":{ / / Target interface
[0095] "metric_params":[{ / / Frequency control statistics field
[0096] "stat_field":"$.client_key"
[0097] }],
[0098] "pre_rule_detail_list":[ / / Pre-frequency control conditions
[0099] {
[0100] "stat_field":"$.opt_status",
[0101] "rule_detail_type":"=",
[0102] "content":"enable"
[0103] }
[0104] ],
[0105] "post_rule_detail_list":[ / / Post frequency control conditions
[0106] {
[0107] "stat_field":"$.execute_time",
[0108] "rule_detail_type":">",
[0109] "content":"10s"
[0110] } ]
[0112] }
[0113] In the above example of the first frequency control configuration, the meaning of each code marked with / / is not repeated here. Among them, in the pre-frequency control condition and post-frequency control condition of the above example:
[0114] stat_field is the conditional field. The value of stat_field is the value after stat_field, or the value of the first specified field following stat_field. For example, taking "stat_field":"$.execute_time" as an example, execute_time is the first specified field, and the value of execute_time is the value of stat_field.
[0115] rule_detail_type is the matching field, and the matching symbol following it represents the matching method represented by the matching field. For example, "rule_detail_type":">" indicates that the matching method represented by rule_detail_type is greater than. Specifically, in this embodiment, matching methods include but are not limited to equal to, not equal to, regular match, contains, numerically greater than, and less than.
[0116] content is the target value field. The value of content is similar to stat_field and will not be repeated here.
[0117] To determine whether the pre-frequency control condition or post-frequency control condition is met, it is to determine whether the value of the condition field matches the value of the target value field according to the matching method represented by the matching field. If they match, it means that the pre-frequency control condition or post-frequency control condition is met. If they do not match, it means that the pre-frequency control condition or post-frequency control condition is not met. For example, take the following frequency control condition as an example:
[0118] "stat_field":"$.execute_time",
[0119] "rule_detail_type":">",
[0120] "content":"10s"
[0121] Assuming the execute_time value is 5 seconds, according to the matching method represented by rule_detail_type, the frequency control condition does not hold because the stat_field value of 5 seconds is not greater than the content value of 10 seconds. However, if the execute_time value is 20 seconds, according to the matching method represented by rule_detail_type, the frequency control condition holds because the stat_field value of 20 seconds is not greater than the content value of 10 seconds.
[0122] Setting frequency control conditions based on condition fields, match fields, and target value fields can meet the frequency control condition settings in different scenarios and is more flexible.
[0123] In combination with the above-mentioned example of the first frequency control configuration, in some embodiments, when multiple pre-frequency control conditions are included, frequency control is performed on the target interface when all of the multiple pre-frequency control conditions are met, and frequency control is not performed on the target interface when any of the pre-frequency control conditions is not met.
[0124] Correspondingly, in the case of multiple post-frequency control conditions, when all of the multiple post-frequency control conditions are met, the frequency control value of the service request is accumulated, and when any of the post-frequency control conditions is not met, the frequency control value of the service request is not accumulated.
[0125] In this way, the frequency control of the target interface is more precise.
[0126] Furthermore, in some embodiments, if the value of the condition field is the value of the first specified field, and the value of the target value field is the value of the second specified field:
[0127] Before determining whether the frequency control condition is met, the method of the present disclosure further includes:
[0128] For any one of the first designated field and the second designated field, in response to the designated field being a field of the first type, the value of the designated field is obtained from the business request, and in response to the designated field being a field of the second type, the value of the designated field is obtained from the designated storage area.
[0129] Specifically, in combination with the above-mentioned example of the first frequency control configuration, stat_field and content can be json_path syntax fields, which support obtaining the value of the specified field from the service request. When the specified field is a first type of field, the $ annotation can be used before the specified field. For example, the opt_status field in the above-mentioned pre-frequency control condition has a $ annotation in front of it, indicating that the opt_status field is in the service request. It is necessary to obtain the value of the field from the service request, and the obtained value is used as the value of the stat_field field.
[0130] Accordingly, when specifying a second-type field, the $ symbol can be omitted before the specified field. This indicates that the specified field is located in the specified storage area, not in the service request. The specified storage area includes, but is not limited to, databases and caches. In this case, the value of the specified field can be obtained from the specified storage area.
[0131] By dividing the specified fields into first-type fields and second-type fields, values can be obtained from both service requests and specified storage areas, making the setting of frequency control conditions more flexible and enabling more refined control of the target interface.
[0132] Combined with the above first frequency control configuration example, refer to Figure 5 , is a schematic diagram of the relationship between the first frequency control configuration and the second frequency control configuration provided in another embodiment of the present disclosure. Figure 5 and Figure 2 、 Figure 3 Basically similar, the main difference is that Figure 5 In the first frequency control configuration and the second frequency control configuration, "configuration content" is added, where the "configuration content" can be used to configure other frequency control conditions in addition to the frequency control threshold, such as the contents identified as the pre-frequency control condition and the post-frequency control condition in the first frequency control configuration example above.
[0133] In addition, the first frequency control configuration also includes "frequency control text". Among them, "frequency control text" can be used to configure the frequency control prompt message after frequency control is performed on the target interface, such as "Hello, your current interface call quota is insufficient!"
[0134] Furthermore, the second frequency control configuration also includes an "effective status" and an "ID." The "effective status" indicates whether the corresponding second frequency control configuration is effective. If the second frequency control configuration is not effective, frequency control operations can be performed on the target interface based on the first frequency control configuration, without having to perform frequency control operations on the target interface based on the second frequency control configuration. The "ID" identifies the second frequency control configuration; different second frequency control configurations can have different IDs.
[0135] It is understandable that in the "configuration content" of the first frequency control configuration and the second frequency control configuration, different frequency control conditions can be configured based on actual frequency control requirements to perform fine frequency control on the target interface in various scenarios.
[0136] In some embodiments, based on the “configuration content”, before executing the service request in response to the above, the pre-frequency control condition is met, and frequency control is performed on the service request, which may include:
[0137] 1) When the pre-condition for frequency control includes multiple preset interfaces, frequency control is performed on the service request in response to the multiple preset interfaces including the target interface in the service request, and the total number of calls to the multiple preset interfaces exceeds the frequency control threshold. This frequency control condition can be used to implement the aforementioned frequency control requirement of "multiple versions of interfaces share the same frequency control threshold."
[0138] 2) In response to the service request including the target parameter, frequency control is performed on the service request. This frequency control condition can be used to implement the above-mentioned frequency control requirement of "performing frequency control when a specified parameter is passed in the interface call request".
[0139] 3) In response to the value of the specified parameter in the service request being the target value, frequency control is performed on the service request. This frequency control condition can be used to implement the above-mentioned frequency control requirements of "frequency control based on the batch request volume in the interface call request" and "frequency control when the specified parameter in the interface call request is the specified value."
[0140] See also Figure 6 , which is an interactive schematic diagram of a frequency control method provided by an embodiment of the present disclosure. Figure 6 The steps include:
[0141] Step S61: The service personnel configures the frequency control through the frequency control configuration interface.
[0142] Specifically, mainly according to Figure 2 、 Figure 3 or Figure 5 The format shown configures the first frequency control configuration and the second frequency control configuration.
[0143] Step S62: Synchronize frequency control configuration.
[0144] Specifically, the first frequency control configuration and the second frequency control configuration are synchronized to the gateway, wherein the pre-frequency control condition can be synchronized to the pre-frequency control gateway, and the post-frequency control condition can be synchronized to the post-frequency control gateway.
[0145] Step S63: The interface caller initiates a call to the target interface.
[0146] The interface caller can be an application or client that calls the target interface.
[0147] Step S64: Perform frequency control determination based on the pre-set frequency control condition.
[0148] Specifically, in this embodiment, the pre-frequency control condition can be used to determine whether the frequency control value corresponding to the service request of the target interface reaches the frequency control threshold. If the pre-frequency control condition is met, step S65 is executed; if the pre-frequency control condition is not met, step S66 is executed.
[0149] Step S65: intercept the service request to perform frequency control on the target interface.
[0150] Specifically, when intercepting a service request, a frequency control prompt may be given to the interface caller based on the "frequency control text" in the first frequency control configuration.
[0151] Step S66: Determine the service request as a normal service request.
[0152] In this case, the functions specified by the business request can be executed normally based on the target interface.
[0153] Step S67: Perform frequency control judgment according to the post-frequency control condition.
[0154] Specifically, if the post-frequency control condition is met, step S68 is executed; if the post-frequency control condition is not met, the process ends.
[0155] Step S68: Accumulate and save the frequency control value.
[0156] Specifically, in this embodiment, if the post-frequency control condition is met, the frequency control value corresponding to the service request including the target interface may be accumulated.
[0157] This completes the description of the disclosed solution.
[0158] See also Figure 7 , which is a module diagram of a frequency control system provided by an embodiment of the present disclosure. Figure 7 The frequency control system includes:
[0159] A request receiving module, configured to receive a service request, wherein the service request includes a target interface to be called;
[0160] A first configuration acquisition module, configured to acquire, in response to a resource identifier associated with the target interface, a first frequency control configuration under the resource identifier, wherein the first frequency control configuration includes a frequency control dimension;
[0161] A second configuration acquisition module is configured to obtain a dimension value corresponding to the frequency control dimension of the service request, and use the resource identifier and the dimension value as a search index to search for a second frequency control configuration matching the search index;
[0162] The frequency control operation module is configured to, in response to finding the second frequency control configuration, perform a frequency control operation on the target interface according to the first frequency control logic included in the second frequency control configuration.
[0163] See also Figure 8 , is a schematic diagram of an electronic device provided by an embodiment of the present disclosure. The electronic device includes a processor and a memory, wherein the memory is used to store a computer program. When the computer program is executed by the processor, the above method is implemented.
[0164] The processor may be a central processing unit (CPU). The processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or a combination of the above chips.
[0165] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer executable programs, and modules, such as the program instructions / modules corresponding to the methods in the embodiments of the present disclosure. The processor executes the non-transitory software programs, instructions, and modules stored in the memory to perform various processor functions and data processing, thereby implementing the methods in the aforementioned method embodiments.
[0166] The memory may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created by the processor, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-transitory memory, such as at least one disk storage device, a flash memory device, or other non-transitory solid-state storage device. In some embodiments, the memory may optionally include a memory remotely located relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0167] An embodiment of the present disclosure further provides a computer-readable storage medium, which is used to store a computer program. When the computer program is executed by a processor, the above method is implemented.
[0168] Although the embodiments of the present disclosure have been described with reference to the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present disclosure, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A frequency control method, characterized in that: The method comprises: receiving a service request, wherein the service request includes a target interface to be called; In response to a resource identifier associated with the target interface, obtaining a first frequency control configuration under the resource identifier, wherein the first frequency control configuration includes a frequency control dimension; Obtaining a dimension value corresponding to the frequency control dimension of the service request, and using the resource identifier and the dimension value as a search index to search for a second frequency control configuration matching the search index; In response to finding the second frequency control configuration, a frequency control operation is performed on the target interface according to the first frequency control logic included in the second frequency control configuration.
2. The method according to claim 1, wherein The first frequency control configuration further includes a second frequency control logic; and the method further includes: In response to not finding the second frequency control configuration, performing a frequency control operation on the service request according to the second frequency control logic.
3. The method according to claim 2, wherein In the first frequency control logic and the second frequency control logic, at least one of the frequency control logics includes a frequency control condition, and the frequency control condition includes a pre-frequency control condition; Performing a frequency control operation on the service request according to the frequency control logic, including: In response to the pre-frequency control condition being met before executing the service request, frequency control is performed on the target interface; In response to the fact that the pre-frequency control condition is not met before executing the service request, frequency control is not performed on the target interface.
4. The method according to claim 3, wherein The frequency control conditions of at least one of the frequency control logics further include a post-frequency control condition; Performing a frequency control operation on the service request according to the frequency control logic, including: In response to executing the service request, based on the execution result of the service request, the post-frequency control condition is met, and the frequency control value of the service request is accumulated, wherein the frequency control value represents the number of service requests that meet the post-frequency control condition.
5. The method according to claim 4, wherein The pre-frequency control condition includes a frequency control threshold; In response to receiving a next service request including the target interface, the method further includes: In response to the frequency control value reaching the frequency control threshold, frequency control is performed on the target interface in the next service request.
6. The method according to claim 3 or 4, wherein: The frequency control condition includes a condition field, a matching field and a target value field, wherein the matching field represents a matching method; In response to satisfying the following conditions, it is determined that the frequency control condition is met: According to the matching method represented by the matching field, the value of the condition field matches the value of the target value field.
7. The method according to claim 6, wherein The value of the condition field is the value of the first specified field, and the value of the target value field is the value of the second specified field: Before determining whether the frequency control condition is met, the method further includes: For any one of the first designated field and the second designated field, in response to the designated field being a field of the first type, the value of the designated field is obtained from the business request, and in response to the designated field being a field of the second type, the value of the designated field is obtained from the designated storage area.
8. The method according to claim 7, wherein The step of: responding to the pre-condition for frequency control being met before executing the service request and performing frequency control on the service request, including: In a case where the pre-condition for frequency control includes multiple preset interfaces, in response to the multiple preset interfaces including the target interface in the service request, and the total number of times the multiple preset interfaces are called exceeds a frequency control threshold, frequency control is performed on the service request; and / or In response to the service request including the target parameter, performing frequency control on the service request; and / or In response to the value of the specified parameter in the service request being a target value, frequency control is performed on the service request.
9. A frequency control system, characterized in that: The system comprises: A request receiving module, configured to receive a service request, wherein the service request includes a target interface to be called; A first configuration acquisition module, configured to acquire, in response to a resource identifier associated with the target interface, a first frequency control configuration under the resource identifier, wherein the first frequency control configuration includes a frequency control dimension; A second configuration acquisition module is configured to obtain a dimension value corresponding to the frequency control dimension of the service request, and use the resource identifier and the dimension value as a search index to search for a second frequency control configuration matching the search index; The frequency control operation module is configured to, in response to finding the second frequency control configuration, perform a frequency control operation on the target interface according to the first frequency control logic included in the second frequency control configuration.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium is used to store a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
11. An electronic device, characterized in that: The electronic device includes a processor and a memory, wherein the memory is used to store a computer program, and when the computer program is executed by the processor, the method according to any one of claims 1 to 8 is implemented.