Flow control method and device and electronic equipment
By presetting the current limiting policy and validity period in the current limiting policy library and automatically loading it into the rule engine, the problem of coupling the configuration time and validity period of the existing current limiting policy is solved, and the automatic configuration of the current limiting policy and efficient flow control are realized. Reduces labor costs and maintenance difficulties.
Patent Information
- Application Number
- CN202310755628.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-25
- Publication Date
- 2024-12-27
AI Technical Summary
The configuration time and validity period of the existing current limiting strategy are strongly coupled, which leads to developers need to monitor whether the system needs current limit in real time, and configure the rule engine every time the system needs current limit, which consumes high labor costs and is low efficiency. , difficult to maintain.
By presetting the current limiting policy and current limiting policy validity period for different business parameters, and storing it in the current limiting policy library, the target current limiting policy that is valid at the current moment is regularly obtained and loaded into the rule engine, and the current limiting policy is automatically configured. According to the parameters matching of service requests and the current limit processing is performed, the configuration time and validity period are decoupled.
The automated configuration of the flow limiting strategy is realized, which reduces labor costs, improves the flexibility and efficiency of flow limiting processing, reduces the difficulty of maintaining the rule engine, and enables the system to control business traffic more flexibly and efficiently.
Smart Images

Figure CN119211128A_ABST
Abstract
Description
Technical Field
[0001] This document relates to the field of computer technology, and in particular to a flow control method, device and electronic equipment. Background Art
[0002] Current limiting is a measure to protect the system by limiting the speed of traffic accessing the system to prevent the system from overloading. Currently, configuring the current limiting strategy in advance to the open source rule engine is a solution to achieve the above current limiting. However, the configuration time and validity period of the current limiting strategy are strongly coupled, requiring developers to monitor in real time whether the system needs current limiting and to configure the rule engine accordingly every time the system needs current limiting to ensure the system's service capabilities. This not only consumes high labor costs and has low efficiency, but also makes the subsequent maintenance of the rule engine very difficult.
[0003] Therefore, there is an urgent need for a more flexible, efficient and easy-to-implement current limiting solution. Summary of the invention
[0004] The purpose of the embodiments of this specification is to provide a flow control method, device and electronic device for decoupling the configuration time and validity period of the flow limiting strategy, thereby not only enabling the system to control business traffic more flexibly and efficiently, but also reducing the complexity and operating cost of the flow limiting configuration.
[0005] In order to achieve the above purpose, the embodiments of this specification adopt the following technical solutions:
[0006] In a first aspect, a flow control method is provided, comprising:
[0007] Based on the validity period of the current limiting policies in the current limiting policy library, obtaining the target current limiting policy valid at the current moment from the current limiting policy library;
[0008] Determine whether the target current limiting strategy matches the service request based on the service parameters carried by the service request received at the current moment and the service parameters corresponding to the target current limiting strategy;
[0009] If so, the service request is subjected to flow limiting processing based on the target flow limiting strategy.
[0010] In a second aspect, a flow control device is provided, comprising:
[0011] A first acquisition module is used to acquire a target current limiting strategy valid at the current moment from the current limiting strategy library based on the validity period of the current limiting strategy in the current limiting strategy library;
[0012] A matching module, configured to determine whether the target current limiting strategy matches the service request based on the service parameters carried by the service request received at the current moment and the service parameters corresponding to the target current limiting strategy;
[0013] The flow control module is used to perform flow limiting processing on the business request based on the target flow limiting strategy when the target flow limiting strategy matches the business request.
[0014] According to a third aspect, an electronic device is provided, including:
[0015] Processor; and
[0016] a memory arranged to store computer executable instructions which, when executed, cause the processor to:
[0017] Based on the validity period of the current limiting policies in the current limiting policy library, obtaining the target current limiting policy valid at the current moment from the current limiting policy library;
[0018] Determine whether the target current limiting strategy matches the service request based on the service parameters carried by the service request received at the current moment and the service parameters corresponding to the target current limiting strategy;
[0019] If so, the service request is subjected to flow limiting processing based on the target flow limiting strategy.
[0020] In a fourth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores one or more programs, and when the one or more programs are executed by an electronic device including a plurality of application programs, the electronic device performs the following operations:
[0021] Based on the validity period of the current limiting policies in the current limiting policy library, obtaining the target current limiting policy valid at the current moment from the current limiting policy library;
[0022] Determine whether the target current limiting strategy matches the service request based on the service parameters carried by the service request received at the current moment and the service parameters corresponding to the target current limiting strategy;
[0023] If so, the service request is subjected to flow limiting processing based on the target flow limiting strategy.
[0024] The scheme of the embodiments of the present specification pre-sets the flow limiting strategies and the validity periods of the flow limiting strategies for different business parameters and stores them in the flow limiting strategy library. The system can obtain the target flow limiting strategy that is valid at the current moment from the flow limiting strategy library based on the validity period of the flow limiting strategy and load it into the rule engine, thereby completing the automatic configuration of the rule engine, and then determining whether the target flow limiting strategy matches the business request based on the business parameters carried by the business request received at the current moment, and then automatically performing flow limiting processing on the business request based on the target flow limiting strategy when matching. In this way, the configuration time of the flow limiting strategy is decoupled from the validity period, so that developers do not need to monitor in real time whether the system needs flow limiting, nor do they need to configure the rule engine every time they monitor that the system needs flow limiting. This is not only easy to maintain and implement, but also reduces labor costs, and enables the system to control business traffic more flexibly and efficiently. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The drawings described herein are used to provide a further understanding of this specification and constitute a part of this specification. The illustrative embodiments and descriptions of this specification are used to explain this specification and do not constitute an improper limitation on this specification. In the drawings:
[0026] Figure 1 A schematic diagram of the architecture of a current limiting system provided for one embodiment of this specification;
[0027] Figure 2 A flow chart of a flow control method provided for one embodiment of this specification;
[0028] Figure 3 A schematic diagram of the structure of a flow control device provided for one embodiment of this specification;
[0029] Figure 4 A schematic diagram of the structure of an electronic device provided for one embodiment of the present specification. DETAILED DESCRIPTION
[0030] In order to make the purpose, technical solutions and advantages of this specification clearer, the technical solutions of this specification will be clearly and completely described below in combination with the specific embodiments of this specification and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of this specification, not all of them. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this document.
[0031] The terms "first", "second", etc. in this specification and claims are used to distinguish similar objects, and are not used to describe a particular order or precedence. It should be understood that the terms used in this way are interchangeable where appropriate so that the embodiments of this specification can be implemented in an order other than those illustrated or described herein. In addition, "and / or" in this specification and claims means at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0032] The terms involved in the embodiments of this specification include:
[0033] Current limiting strategy: A configuration set according to business parameters to control business traffic.
[0034] Rule Engine: A component embedded in an application that separates the throttling strategy from the application code and uses predefined semantic modules to write throttling strategies that can be configured and managed by users or developers.
[0035] As mentioned above, the current configuration time and validity period of the current limiting strategy are strongly coupled, requiring developers to monitor in real time whether the system needs current limiting and configure the rule engine accordingly every time the system needs current limiting to ensure the system's service capabilities. This not only consumes high labor costs and has low efficiency, but also makes the subsequent maintenance of the rule engine very difficult.
[0036] To this end, the embodiments of the present specification aim to provide a flow control solution, by pre-setting flow limiting strategies and the validity period of the flow limiting strategies for different business parameters and storing them in a flow limiting strategy library, and periodically obtaining the target flow limiting strategy that is valid at the current moment from the flow limiting strategy library based on the validity period of the flow limiting strategy and loading it into the rule engine, thereby completing the automatic configuration of the rule engine, and then determining whether the target flow limiting strategy matches the business request based on the business parameters carried by the business request received at the current moment, and then automatically performing flow limiting processing on the business request based on the target flow limiting strategy when matching. In this way, the configuration time of the flow limiting strategy is decoupled from the validity period, so that developers do not need to monitor in real time whether the system needs flow limiting, nor do they need to configure the rule engine every time they monitor that the system needs flow limiting. This is not only easy to maintain and implement, but also reduces labor costs, and can also control business traffic more flexibly and efficiently.
[0037] It should be understood that the flow control method provided in the embodiments of this specification can be applied to a current limiting system that performs current limiting processing, and can be specifically executed by the current limiting system or by software set in the current limiting system.
[0038] The technical solutions provided by the embodiments of this specification are described in detail below in conjunction with the accompanying drawings.
[0039] The flow control method provided by one or more embodiments of this specification can be performed by Figure 1 The current limiting system shown is implemented. Figure 1 As shown, the current limiting system includes: an access layer, a policy matching layer, a Redis shard routing layer, a current limiting algorithm layer, and a storage and computing layer.
[0040] The access layer provides current limiting service capabilities, which are used by peripheral systems to obtain current limiting system configuration, current limiting policy management, and current limiting service functions through Remote Procedure Call Protocol (RPC) calls (such as Dubbo).
[0041] The policy matching layer is used to match the received business request with the preset flow limiting policy to determine the flow limiting policy applicable to the business request. Specifically, the policy matching layer can match the business request with the flow limiting policy using a preset matching method (such as simple rule matching). Furthermore, after determining the flow limiting policy that matches the business request, the matching flow limiting policy can be loaded into the rule engine, wherein the rule engine can, for example, include but is not limited to at least one of the following engines: expression tree engine, external open source rule engine, etc.
[0042] The Redis shard routing layer can be used to route received business requests to the corresponding Redis shards based on the Redis shard mode that matches the received business requests, and the corresponding Redis shards will perform current limiting processing. Specifically, if a certain type of business request has high requirements for the accuracy of the processing results, the Redis single shard mode is used to route such business requests to a single Redis shard; if a certain type of business request has high requirements for performance, a preset random algorithm can be used to evenly distribute such business requests to multiple Redis shards, thereby avoiding excessive load on a single Redis shard and affecting performance.
[0043] The current limiting algorithm layer provides the current limiting processing capability for the service traffic. When it is determined that the received service request reaches the corresponding current limiting threshold, it can use the corresponding current limiting algorithm to limit the received service request, such as rejecting the service request, downgrading the service request, etc. Among them, the current limiting algorithm can include, but is not limited to, at least one of the following algorithms: counter algorithm, token bucket algorithm, and funnel algorithm. In specific applications, the current limiting thresholds corresponding to different current limiting algorithms can be different, which can be set according to actual needs, and the embodiments of this specification do not limit this.
[0044] The storage and computing layer can provide storage, configuration, and calculation of current limiting related parameters. For example, the storage and computing layer can analyze and determine the current limiting algorithms and corresponding current limiting thresholds for various types of services, as well as configure and store business parameters for various types of services, current limiting strategies for various types of services (such as current limiting algorithms and corresponding current limiting thresholds), and the validity period of current limiting strategies. Therefore, through the storage and computing layer, the current limiting strategy and other current limiting related parameters can be flexibly configured and modified in a timely manner, thereby reducing the risk of current limiting and improving the service capabilities of the current limiting system.
[0045] Of course, in practical applications, the current limiting system of the embodiment of this specification can also include more structures, which can be set according to actual needs, and the embodiment of this specification does not limit this. In addition, the current limiting system of the embodiment of this specification can also have functions such as timeout fuse, service degradation, cache management, data management, monitoring log and permission control, which will not be elaborated in detail here.
[0046] Please refer to Figure 2 , is a flow chart of a flow control method provided by an embodiment of this specification, the method may include:
[0047] S202: Based on the validity period of the current limiting policies in the current limiting policy library, obtain the target current limiting policy that is valid at the current moment from the current limiting policy library.
[0048] Among them, the current limiting strategy library stores multiple pre-configured current limiting strategies, and each current limiting strategy is used to perform corresponding current limiting processing. Specifically, each current limiting strategy has corresponding business parameters, and the business parameters corresponding to each current limiting strategy are used to indicate that the current limiting strategy is used to limit the business traffic with the business parameters. Specifically, the business parameters may, for example, include but are not limited to: business type, business initiator, business acceptor, computer room for processing business, etc. It should be noted that the business parameters corresponding to each current limiting strategy can be set according to actual needs, and the embodiments of this specification do not limit this.
[0049] Each current limiting strategy may also have a corresponding validity period. In the embodiments of this specification, according to the different validity periods, the current limiting strategies can be divided into real-time current limiting strategies and timed current limiting strategies, wherein the real-time current limiting strategy refers to a current limiting strategy with a validity period of real time (that is, it can take effect after being loaded into the rule engine), and the timed current limiting strategy refers to a current limiting strategy with a validity period of a preset time period. It should be noted that the validity period of each current limiting strategy can be set according to actual needs, and the embodiments of this specification do not limit this. For example, the validity period of a normalized current limiting strategy (such as a current limiting strategy with a higher frequency of use) can be set to real-time validity, while the validity period of a current limiting strategy for temporary needs can be set to a certain time period.
[0050] In addition, each current limiting strategy may indicate the current limiting algorithm used for current limiting and the current limiting threshold corresponding to the current limiting algorithm. The current limiting algorithm may include, for example, but is not limited to, at least one of the following algorithms: a counter algorithm, a token bucket algorithm, and a funnel algorithm, etc. The current limiting threshold corresponding to the counter algorithm may include a threshold of the number of requests per unit time, etc. The current limiting threshold corresponding to the token bucket algorithm may include a capacity threshold of the token bucket and a token input rate, etc. The current limiting threshold corresponding to the funnel algorithm includes a capacity threshold of the funnel and an output rate, etc.
[0051] In specific applications, the current limiting algorithm indicated by each current limiting strategy and the current limiting threshold corresponding to the current limiting algorithm can be set according to actual needs, and the embodiments of this specification do not limit this.
[0052] Considering that the service processing links for processing different services may be different, the performance of different service processing links may be different, which in turn leads to different carrying capacities for service traffic of different services. Based on this, in order to fully utilize the service carrying capacity of the service processing link and ensure the reliability of current limiting processing, in an optional implementation scheme, corresponding current limiting algorithms and current limiting thresholds may be set for different services based on the performance of the service processing links corresponding to different services. Specifically, the flow control method provided in the embodiments of this specification may also include a method for setting a current limiting algorithm and a current limiting threshold, which specifically includes:
[0053] Step B1, obtaining the service demand flow of different services in unit time.
[0054] In specific applications, for various types of services, the service demand flow of the service within a unit time can be analyzed based on the historical flow of the service within a unit time (such as the number of historical requests received within a unit time). The specific analysis method can adopt various methods known to those skilled in the art, such as machine learning, statistical analysis, etc., and this specification embodiment does not limit this.
[0055] Step B2: for each type of service, based on the service demand flow of the service in unit time, determine the performance indicator data of the service processing link corresponding to the service demand flow.
[0056] In specific applications, for each type of business, the business processing link corresponding to the business can be isolated; then, the business demand traffic is input to the entrance of the business processing link within a unit time and the performance indicators of the business processing link (such as the utilization rate of the central processing unit CPU, memory occupancy, disk occupancy, etc.) are monitored; further, by analyzing the monitoring results, the performance indicator data of the business processing link corresponding to the business demand traffic is determined.
[0057] Step B3, based on the performance indicator data of the service processing link corresponding to the service demand flow, determine the flow limiting algorithm and flow limiting threshold corresponding to the service parameters of the service.
[0058] Since the performance indicator data of the service processing link corresponding to the service demand flow corresponding to a certain service can reflect the carrying capacity of the service processing link for the service demand flow, by analyzing the performance indicator data, the maximum service flow that the service processing link can carry for the corresponding service and the flow limiting algorithm suitable for the performance of the service processing link can be determined, and further, the determined flow limiting algorithm can be used as the flow limiting algorithm corresponding to the service parameters of the service, and the flow limiting threshold corresponding to the service parameters of the service can be determined based on the determined maximum service flow. The specific analysis method can adopt various methods known to those skilled in the art, such as machine learning, statistical analysis, etc., and the embodiments of this specification do not limit this.
[0059] For example, the following Table 1 shows examples of real-time current limiting strategy and timed current limiting strategy.
[0060] Table 1
[0061]
[0062] Specifically, in the above step S202, since each flow limiting strategy in the flow limiting strategy library has a corresponding validity period, the flow limiting system can obtain the target flow limiting strategy that is valid at the current moment from the flow limiting strategy library and load it into the rule engine, and then use the rule engine to perform flow limiting processing on the business traffic received at the current moment.
[0063] To ensure that the target current limiting strategy obtained from the current limiting strategy library is valid at the current moment, in an optional implementation, the above S202 may include the following steps:
[0064] Step A1, obtaining a candidate current limiting strategy whose validity period includes the current time from the current limiting strategy library.
[0065] Specifically, for each current limiting strategy in the current limiting strategy library, if the validity period of the current limiting strategy is real-time, then the current limiting strategy can be determined as a candidate current limiting strategy; if the preset time period indicated by the validity period of the current limiting strategy includes the current time, then the current limiting strategy can be determined as a candidate current limiting strategy.
[0066] For example, using the current limiting strategy shown in Table 1 above, if the current time is 2021-10-01 09:00, at this time, current limiting strategy 1 and current limiting strategy 3 are not in effect, and current limiting strategy 2 is valid, then current limiting strategy 2 can be determined as a candidate current limiting strategy; if the current time is 2021-10-01 10:00, current limiting strategy 1 is in effect, and current limiting strategy 2 and current limiting strategy 3 are both valid, then current limiting strategy 1, current limiting strategy 3 and current limiting strategy 3 can all be determined as candidate current limiting strategies; if the current time is 2021-10-02 0:00, at this time, current limiting strategy 1 and current limiting strategy 3 are both invalid, and current limiting strategy 2 is valid, then current limiting strategy 2 can be determined as a candidate current limiting strategy.
[0067] Step A2: Determine a target current limiting strategy based on the obtained candidate current limiting strategies.
[0068] In an optional manner, the obtained candidate current limiting strategy may be determined as the target current limiting strategy.
[0069] Considering that when multiple candidate current limiting strategies are obtained, there may be conflicts between some or all of the candidate current limiting strategies. For example, in the above example, when the current time is 2021-10-01 10:00, there is a conflict between current limiting strategy 1 and current limiting strategy 2 in the obtained candidate current limiting strategies. If these candidate current limiting strategies are all determined as target current limiting strategies, it may cause errors in the subsequent current limiting process. In view of this, in another optional way, in order to ensure the reliability of subsequent business traffic flow limiting, the above step A2 can be specifically implemented as follows: if the obtained candidate current limiting strategies include the first current limiting strategy and the second current limiting strategy, then based on the business parameters corresponding to the first current limiting strategy and the second current limiting strategy, determine whether there is a conflict between the first current limiting strategy and the second current limiting strategy, wherein the first current limiting strategy refers to a current limiting strategy with a validity period of real-time validity, and the second current limiting strategy refers to a current limiting strategy with a validity period of a preset time period and the preset time period includes the current time; if there is a conflict between the first current limiting strategy and the second current limiting strategy, the second current limiting strategy is determined as the target current limiting strategy.
[0070] For example, continuing with the above example, when the current time is 2021-10-01 10:00, there is a conflict between current limiting strategy 1 and current limiting strategy 2 in the obtained candidate current limiting strategies, then current limiting strategy 2 is discarded and current limiting strategy 1 is retained.
[0071] Furthermore, in order to ensure the comprehensiveness of the target current limiting strategy obtained, further improve the current limiting capability of the current limiting system, and avoid business traffic overload, after determining whether the first current limiting strategy conflicts with the second current limiting strategy, the above step A2 can also be specifically implemented as follows: if the first current limiting strategy does not conflict with the second current limiting strategy, the first current limiting strategy and the second current limiting strategy are determined as the target current limiting strategy.
[0072] For example, continuing with the above example, when the current time is 2021-10-01 10:00, there is no conflict between current limiting strategy 1 and current limiting strategy 3 in the obtained candidate current limiting strategies, then current limiting strategy 1 and current limiting strategy 3 are both determined as target current limiting strategies.
[0073] In another optional method, considering that when only the first current limiting strategy or the second current limiting strategy is obtained, there is usually no conflict between the current limiting strategies. In this regard, in order to ensure the comprehensiveness of the obtained target current limiting strategy, further improve the current limiting capability of the current limiting system, and avoid business traffic overload, the above step A2 can be specifically implemented as follows: if the obtained candidate current limiting strategy includes the first current limiting strategy or the second current limiting strategy, the obtained candidate current limiting strategy is determined as the target current limiting strategy.
[0074] For example, still using the above example, when the current time is 2021-10-01 09:00 or 2021-10-02 0:00, the obtained candidate current limiting strategies only include current limiting strategy 2, then the obtained candidate current limiting strategy can be determined as the target current limiting strategy.
[0075] The embodiment of this specification shows a specific implementation of the above step S202. Of course, it should be understood that step S202 can also be implemented in other ways, which is not limited in the embodiment of this specification.
[0076] It should also be noted that in actual applications, the validity period of each current limiting strategy
[0077] S204: Determine whether the target current limiting policy matches the service request based on the service parameters carried in the service request received at the current moment and the service parameters corresponding to the target current limiting policy.
[0078] The target current limiting strategy matches the business request, which means that the target current limiting strategy can be used to perform current limiting processing on the business request.
[0079] Specifically, since the service parameters corresponding to each flow limiting strategy are used to indicate that the flow limiting strategy is used to limit the flow of the service traffic with the service parameters, the service parameters carried by the service request received at the current moment are matched with the service parameters corresponding to the target flow limiting strategy, and based on the obtained matching result, it can be determined whether the target flow limiting strategy matches the service request. More specifically, if the service parameters carried by the service request received at the current moment match the service parameters corresponding to the target flow limiting strategy, it can be determined that the target flow limiting strategy matches the service request received at the current moment.
[0080] For example, continuing with the above example, if the current time is 2021-10-01 09:00, the target flow limiting strategy determined is flow limiting strategy 2. If the business request received at this time is initiated by organization A, it is determined that flow limiting strategy 2 matches the business request, and the business request can be subsequently flow limited based on flow limiting strategy 2.
[0081] S206: If yes, the service request is subjected to flow limiting processing based on the target flow limiting strategy.
[0082] Specifically, the service request can be subjected to flow limiting processing based on the flow limiting algorithm indicated by the target flow limiting strategy and the flow limiting threshold corresponding to the flow limiting algorithm. More specifically, the flow limiting algorithm indicated by the target flow limiting strategy determines whether the number of service requests reaches the flow limiting threshold corresponding to the flow limiting algorithm. If so, flow limiting of the service request is triggered.
[0083] For example, if the flow limiting algorithm indicated by the target flow limiting policy is a counter algorithm, when the number of business requests received that match the target flow limiting policy exceeds the request number threshold per unit time indicated by the target flow limiting policy and the interval time between the business request received at this time and the first business request received exceeds the unit time, then the subsequently received business requests will be flow limited, such as rejecting the business request, downgrading the service of the business request, etc.
[0084] If the target current limiting policy indicates that the current limiting algorithm is the token bucket algorithm, tokens are input into the token bucket at the token input rate corresponding to the current limiting algorithm, and when the number of tokens in the token bucket exceeds the capacity threshold of the token bucket, the input of tokens into the token bucket is stopped; at the same time, each time a business request matching the target current limiting policy is received, a token is taken out of the token bucket for the business request. When the token cannot be taken out of the token bucket, the subsequent business requests received are current limited, such as rejecting the business request, downgrading the service of the business request, etc.
[0085] If the target current limiting strategy indicates that the current limiting algorithm is the funnel algorithm, then each time a service request matching the target current limiting strategy is received, the service request is added to the funnel, and the service request is taken out of the funnel for processing at the output rate corresponding to the current limiting algorithm. When the number of service requests in the funnel exceeds the capacity threshold of the funnel, the subsequent service requests received are current limited, such as rejecting the service request, downgrading the service of the service request, etc.
[0086] The embodiment of this specification shows a specific implementation of the above step S206. Of course, it should be understood that step S206 can also be implemented in other ways, which is not limited in the embodiment of this specification.
[0087] It should be noted that in actual applications, the current limiting system can execute the above-mentioned flow control method when needed, or it can also execute the above-mentioned flow control method regularly according to a preset time interval, wherein the preset time interval can be set according to actual business needs, such as executing the above-mentioned flow control method every 1 hour, and the embodiments of this specification do not limit this.
[0088] The flow control method provided in the embodiments of the present specification pre-sets flow limiting strategies and validity periods of flow limiting strategies for different business parameters and stores them in a flow limiting strategy library, obtains the target flow limiting strategy valid at the current moment from the flow limiting strategy library based on the validity period of the flow limiting strategy and loads it into the rule engine, thereby completing the automatic configuration of the rule engine, and then determines whether the target flow limiting strategy matches the business request based on the business parameters carried by the business request received at the current moment, and then automatically performs flow limiting processing on the business request based on the target flow limiting strategy when matching. In this way, the configuration time of the flow limiting strategy is decoupled from the validity period, so that developers do not need to monitor in real time whether the system needs flow limiting, nor do they need to configure the rule engine every time they monitor that the system needs flow limiting. This is not only easy to maintain and implement, but also reduces labor costs, and can control business traffic more flexibly and efficiently.
[0089] In addition, Figure 2 Corresponding to the flow control method shown, the embodiment of this specification also provides a flow control device. Figure 3 : is a schematic diagram of a flow control device 300 provided in an embodiment of this specification, including:
[0090] A first acquisition module 310 is used to acquire a target current limiting strategy valid at the current moment from the current limiting strategy library based on the validity period of the current limiting strategy in the current limiting strategy library;
[0091] A matching module 320 is used to determine whether the target current limiting policy matches the service request based on the service parameters carried by the service request received at the current moment and the service parameters corresponding to the target current limiting policy;
[0092] The flow control module 330 is used to perform flow limiting processing on the service request based on the target flow limiting strategy when the target flow limiting strategy matches the service request.
[0093] The flow control device provided in the embodiment of the present specification pre-sets flow limiting strategies and validity periods of flow limiting strategies for different business parameters and stores them in a flow limiting strategy library. It obtains the target flow limiting strategy valid at the current moment from the flow limiting strategy library based on the validity period of the flow limiting strategy and loads it into the rule engine at a fixed time, thereby completing the automatic configuration of the rule engine. Then, based on the business parameters carried by the business request received at the current moment, it determines whether the target flow limiting strategy matches the business request, and then automatically performs flow limiting processing on the business request based on the target flow limiting strategy when matching. In this way, the configuration time of the flow limiting strategy is decoupled from the validity period, so that developers do not need to monitor in real time whether the system needs flow limiting, nor do they need to configure the rule engine every time they monitor that the system needs flow limiting. This is not only easy to maintain and implement, but also reduces labor costs, and can control business traffic more flexibly and efficiently.
[0094] Optionally, the first acquisition module includes:
[0095] A first acquisition submodule is used to obtain a candidate current limiting strategy whose validity period includes the current time from the current limiting strategy library;
[0096] The first determination submodule is used to determine the target current limiting strategy based on the obtained candidate current limiting strategies.
[0097] Optionally, the first determining submodule is used to:
[0098] If the obtained candidate current limiting strategies include a first current limiting strategy and a second current limiting strategy, then based on the business parameters corresponding to the first current limiting strategy and the second current limiting strategy, determine whether the first current limiting strategy conflicts with the second current limiting strategy, the first current limiting strategy refers to a current limiting strategy whose validity period is real-time, and the second current limiting strategy refers to a current limiting strategy whose validity period is a preset time period and the preset time period includes the current time;
[0099] If so, the second current limiting strategy is determined as the target current limiting strategy.
[0100] Optionally, the first determining submodule is further used for:
[0101] After determining whether the first current limiting strategy conflicts with the second current limiting strategy, if the first current limiting strategy does not conflict with the second current limiting strategy, the first current limiting strategy and the second current limiting strategy are determined as the target current limiting strategy.
[0102] Optionally, the first determining submodule is used to:
[0103] If the obtained candidate current limiting strategy includes the first current limiting strategy or the second current limiting strategy, the obtained candidate current limiting strategy is determined as the target current limiting strategy.
[0104] Optionally, the flow control module includes:
[0105] A flow control submodule, configured to perform flow limiting processing on the service request based on the flow limiting algorithm indicated by the target flow limiting strategy and the flow limiting threshold corresponding to the flow limiting algorithm;
[0106] Among them, the current limiting algorithm includes at least one of the following algorithms: counter algorithm, token bucket algorithm and funnel algorithm. The current limiting threshold corresponding to the counter algorithm includes the request number threshold per unit time, the current limiting threshold corresponding to the token bucket algorithm includes the capacity threshold of the token bucket and the token input rate, and the current limiting threshold corresponding to the funnel algorithm includes the capacity threshold and output rate of the funnel.
[0107] Optionally, the flow control device further comprises:
[0108] A second acquisition module is used to obtain the service demand flow of different services within a unit time before the flow control submodule performs flow limiting processing on the service request based on the target flow limiting strategy;
[0109] The second determination submodule is used to determine, for each type of service, performance indicator data of a service processing link corresponding to the service demand flow rate based on the service demand flow rate of the service within a unit time, and
[0110] The third determination submodule is used to determine the current limiting algorithm and current limiting threshold corresponding to the service parameters of the service based on the performance indicator data.
[0111] Optionally, the service parameters include at least one of the following parameters: service type, service initiator, service acceptor, and a computer room for processing the service.
[0112] Obviously, the flow control device of the embodiment of this specification can be used as the above Figure 2 The execution subject of the flow control method shown in FIG. Figure 2 The functions realized are as follows. Since the principles are the same, they will not be described here.
[0113] Figure 4 This is a schematic diagram of the structure of an electronic device according to an embodiment of this specification. Figure 4At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. The memory may include a memory, such as a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. Of course, the electronic device may also include hardware required for other services.
[0114] The processor, network interface and memory can be interconnected through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0115] The memory is used to store the program. Specifically, the program may include a program code, and the program code includes a computer operation instruction. The memory may include a memory and a non-volatile memory, and provides instructions and data to the processor.
[0116] The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a flow control device at the logical level. The processor executes the program stored in the memory and is specifically used to perform the following operations:
[0117] Based on the validity period of the current limiting policies in the current limiting policy library, obtaining the target current limiting policy valid at the current moment from the current limiting policy library;
[0118] Determine whether the target current limiting strategy matches the service request based on the service parameters carried by the service request received at the current moment and the service parameters corresponding to the target current limiting strategy;
[0119] If so, the service request is subjected to flow limiting processing based on the target flow limiting strategy.
[0120] The above is as in this manual Figure 2The method performed by the flow control device disclosed in the illustrated embodiment can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in the form of software. The above processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of this specification can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of this specification can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0121] It should be understood that the electronic device of the embodiment of this specification can realize the flow control device in Figure 2 Functions of the embodiments shown. Since the principles are the same, the embodiments of this specification will not be described in detail here.
[0122] Of course, in addition to software implementation, the electronic device of this specification does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0123] The embodiment of the present specification also provides a computer-readable storage medium, which stores one or more programs, wherein the one or more programs include instructions, which, when executed by a portable electronic device including a plurality of application programs, enable the portable electronic device to execute Figure 2 The method of the embodiment shown is specifically used to perform the following operations:
[0124] Based on the validity period of the current limiting policies in the current limiting policy library, obtaining the target current limiting policy valid at the current moment from the current limiting policy library;
[0125] Determine whether the target current limiting strategy matches the service request based on the service parameters carried by the service request received at the current moment and the service parameters corresponding to the target current limiting strategy;
[0126] If so, the service request is subjected to flow limiting processing based on the target flow limiting strategy.
[0127] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0128] In short, the above description is only a preferred embodiment of this specification and is not intended to limit the protection scope of this specification. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this specification shall be included in the protection scope of this specification.
[0129] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0130] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0131] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0132] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
Claims
1. A flow control method, characterized in that: include: Based on the validity period of the current limiting policies in the current limiting policy library, obtaining the target current limiting policy valid at the current moment from the current limiting policy library; Determine whether the target current limiting strategy matches the service request based on the service parameters carried by the service request received at the current moment and the service parameters corresponding to the target current limiting strategy; If so, the service request is subjected to flow limiting processing based on the target flow limiting strategy.
2. The method according to claim 1, characterized in that The step of obtaining a target current limiting strategy valid at the current moment from the current limiting strategy library based on the validity period of the current limiting strategy in the current limiting strategy library includes: Obtaining a candidate current limiting strategy whose validity period includes the current time from the current limiting strategy library; Based on the obtained candidate current limiting strategies, the target current limiting strategy is determined.
3. The method according to claim 2, characterized in that The step of determining the target current limiting strategy based on the obtained candidate current limiting strategy includes: If the obtained candidate current limiting strategies include a first current limiting strategy and a second current limiting strategy, then based on the business parameters corresponding to the first current limiting strategy and the second current limiting strategy, determine whether the first current limiting strategy conflicts with the second current limiting strategy, the first current limiting strategy refers to a current limiting strategy whose validity period is real-time, and the second current limiting strategy refers to a current limiting strategy whose validity period is a preset time period and the preset time period includes the current time; If so, the second current limiting strategy is determined as the target current limiting strategy.
4. The method according to claim 3, characterized in that After determining whether the first current limiting strategy conflicts with the second current limiting strategy, determining the target current limiting strategy based on the obtained candidate current limiting strategy further includes: If the first current limiting strategy does not conflict with the second current limiting strategy, the first current limiting strategy and the second current limiting strategy are determined as the target current limiting strategy.
5. The method according to claim 2, characterized in that: The step of determining the target current limiting strategy based on the obtained candidate current limiting strategy includes: If the obtained candidate current limiting strategy includes the first current limiting strategy or the second current limiting strategy, the obtained candidate current limiting strategy is determined as the target current limiting strategy.
6. The method according to claim 1, characterized in that The performing flow limiting processing on the service request based on the target flow limiting strategy includes: Based on the current limiting algorithm indicated by the target current limiting strategy and the current limiting threshold corresponding to the current limiting algorithm, the service request is subjected to current limiting processing; Among them, the current limiting algorithm includes at least one of the following algorithms: counter algorithm, token bucket algorithm and funnel algorithm. The current limiting threshold corresponding to the counter algorithm includes the request number threshold per unit time, the current limiting threshold corresponding to the token bucket algorithm includes the capacity threshold of the token bucket and the token input rate, and the current limiting threshold corresponding to the funnel algorithm includes the capacity threshold and output rate of the funnel.
7. The method according to claim 6, characterized in that Before performing flow limiting processing on the service request based on the target flow limiting strategy, the method further includes: Obtain the business demand flow of different businesses within a unit time; For each type of service, based on the service demand flow of the service in a unit time, determine the performance indicator data of the service processing link corresponding to the service demand flow, and, Based on the performance indicator data, a current limiting algorithm and a current limiting threshold corresponding to the service parameters of the service are determined.
8. The method according to any one of claims 1 to 7, characterized in that The service parameters include at least one of the following parameters: service type, service initiator, service acceptor, and a computer room for processing the service.
9. A flow control device, comprising: A first acquisition module is used to acquire a target current limiting strategy valid at the current moment from the current limiting strategy library based on the validity period of the current limiting strategy in the current limiting strategy library; A matching module, configured to determine whether the target current limiting strategy matches the service request based on the service parameters carried by the service request received at the current moment and the service parameters corresponding to the target current limiting strategy; The flow control module is used to perform flow limiting processing on the business request based on the target flow limiting strategy when the target flow limiting strategy matches the business request.
10. An electronic device comprising: processor; as well as a memory arranged to store computer executable instructions which, when executed, cause the processor to: Based on the validity period of the current limiting policies in the current limiting policy library, obtaining the target current limiting policy valid at the current moment from the current limiting policy library; Determine whether the target current limiting strategy matches the service request based on the service parameters carried by the service request received at the current moment and the service parameters corresponding to the target current limiting strategy; If so, the service request is subjected to flow limiting processing based on the target flow limiting strategy.