Flow control method and device, storage medium and electronic device
By obtaining multiple parameter values and controlling traffic to the business unit based on these values, the Sentinel flow control framework is solved, and more refined and effective traffic management is achieved.
Patent Information
- Application Number
- CN202410665745.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-27
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2044-05-27
AI Technical Summary
The existing Sentinel flow control framework cannot effectively control the traffic of business units and cannot meet the needs of large-scale business systems.
By obtaining multiple parameter values from the parameter value set, such as the number of query times, response time, CPU usage, memory usage and time nodes of the business unit, and traffic control of the business unit based on these parameter values.
It realizes more refined and effective traffic control of business units, which can better respond to the needs of large-scale business systems.
Smart Images

Figure CN119484405A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of smart home technology, and more specifically, to a flow control method and device, a storage medium, and an electronic device. Background Art
[0002] With the popularity of microservices, the stability between services is becoming more and more important. Sentinel flow control framework is an open source flow control framework. Its flow control rules are determined by simple parameters. Specifically, it simply monitors the parameter value of a parameter and then determines whether to trigger the flow limit based on whether the parameter value meets the preset conditions. However, this flow control rule cannot meet the needs of large-scale business systems.
[0003] With regard to the problem in related technologies that the flow control framework cannot effectively control the flow of business units, no effective solution has been proposed yet.
[0004] Therefore, it is necessary to improve the related technology to overcome the above-mentioned defects in the related technology. Summary of the invention
[0005] The embodiments of the present application provide a flow control method and device, a storage medium, and an electronic device to at least solve the problem that the flow control framework cannot properly control the flow of the business unit.
[0006] According to one aspect of an embodiment of the present application, a flow control method is provided, comprising: obtaining N parameter values from a parameter value set, wherein the parameter value set includes at least two of the following: the number of queries processed by the business unit in each time unit, the response time of the business unit, the usage rate of the central processing unit CPU of the target device running the business unit, the memory occupancy of the business unit, and the time node when the target device runs the business unit; N is an integer greater than or equal to 2; and flow control is performed on the business unit according to the N parameter values.
[0007] In an exemplary embodiment, the business unit is flow controlled according to the N parameter values, including: when the response time is greater than or equal to the first response time, the business unit is flow controlled according to the CPU usage; and / or when the response time is greater than or equal to the second response time and less than the first response time, the business unit is flow controlled according to the number of queries.
[0008] In an exemplary embodiment, flow control is performed on the business unit according to the CPU usage rate, including: when the CPU usage rate is less than a first usage rate, flow control is performed on the business unit according to the memory occupancy; when the CPU usage rate is greater than or equal to the first usage rate, flow control is performed on the business unit according to the time node.
[0009] In an exemplary embodiment, flow control is performed on the business unit based on the number of queries, including: when the number of queries is greater than or equal to the preset number of queries, flow control is performed on the business unit according to the time node; and / or when the number of queries is less than the preset number of queries, no flow limiting is performed on the business unit.
[0010] In an exemplary embodiment, flow control is performed on the business unit according to the time node, including: when the time node is a stress test time node, no flow limiting is performed on the business unit; and / or when the time node is not the stress test time node, flow control is performed on the business unit according to the CPU usage rate.
[0011] In an exemplary embodiment, flow control is performed on the business unit according to the usage rate of the CPU, including: when the time node is a preset time node, determining a preset usage rate corresponding to the preset time node; and flow control is performed on the business unit according to the relationship between the CPU usage rate and the preset usage rate.
[0012] In an exemplary embodiment, before obtaining N parameter values from a parameter value set, the method further includes: upon monitoring that the traffic control rules are updated in the configuration center, obtaining the traffic control rules from the configuration center; wherein the traffic control rules are used to indicate obtaining the N parameter values from the parameter value set and performing traffic control on the business unit according to the N parameter values.
[0013] According to another aspect of an embodiment of the present application, a flow control device is provided, including: an acquisition module, used to obtain N parameter values from a parameter value set, wherein the parameter value set includes at least two of the following: the number of queries processed by the business unit in each time unit, the response time of the business unit, the usage rate of the central processing unit CPU of the target device running the business unit, the memory occupancy of the business unit, and the time node when the target device runs the business unit; N is an integer greater than or equal to 2; and a control module, used to perform flow control on the business unit according to the N parameter values.
[0014] In an exemplary embodiment, the control module is used to perform flow control on the business unit according to the N parameter values in the following manner: when the response time is greater than or equal to the first response time, the business unit is flow controlled according to the CPU usage rate; and / or when the response time is greater than or equal to the second response time and less than the first response time, the business unit is flow controlled according to the number of queries.
[0015] In an exemplary embodiment, the control module is used to perform flow control on the business unit according to the CPU usage in the following manner: when the CPU usage is less than a first usage, the business unit is flow controlled according to the memory occupancy; when the CPU usage is greater than or equal to the first usage, the business unit is flow controlled according to the time node.
[0016] In an exemplary embodiment, the control module is used to control the flow of the business unit according to the number of queries in the following manner: when the number of queries is greater than or equal to the preset number of queries, the flow of the business unit is controlled according to the time node; and / or when the number of queries is less than the preset number of queries, the flow of the business unit is not limited.
[0017] In an exemplary embodiment, the control module is used to perform flow control on the business unit according to the time node in the following manner: when the time node is a stress test time node, no flow limiting is performed on the business unit; and / or when the time node is not the stress test time node, flow control is performed on the business unit according to the CPU usage rate.
[0018] In an exemplary embodiment, the control module is used to perform flow control on the business unit according to the CPU usage rate in the following manner: when the time node is a preset time node, determine a preset usage rate corresponding to the preset time node; and perform flow control on the business unit according to the relationship between the CPU usage rate and the preset usage rate.
[0019] In an exemplary embodiment, the acquisition module is also used to obtain the traffic control rules from the configuration center before obtaining N parameter values from the parameter value set, upon monitoring that the traffic control rules are updated in the configuration center; wherein the traffic control rules are used to indicate that the N parameter values are obtained from the parameter value set, and traffic control is performed on the business unit based on the N parameter values.
[0020] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium includes a stored program, wherein the computer program is configured to execute the above-mentioned flow control method when running.
[0021] According to another aspect of the embodiments of the present application, there is also provided an electronic device, including a memory and a processor, wherein the memory stores a computer program, wherein the processor is configured to execute the above-mentioned flow control method through the computer program.
[0022] According to another aspect of the embodiments of the present application, a computer program product is provided, including a computer program, and the computer program performs the above-mentioned flow control method when executed by a processor.
[0023] Through the present application, the flow of the business unit is controlled according to at least two parameters in the parameter value set, thereby solving the problem that the flow control framework cannot better control the flow of the business unit, and thus the flow of the business unit can be better controlled. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0025] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0026] Figure 1 is a schematic diagram of a hardware environment of a flow control method according to an embodiment of the present application;
[0027] Figure 2 is a flow chart of a flow control method according to an embodiment of the present application;
[0028] Figure 3 is a schematic diagram of a flow control rule according to an embodiment of the present application;
[0029] Figure 4 is an overall schematic diagram of a flow control method according to an embodiment of the present application;
[0030] Figure 5 It is a structural block diagram of a flow control device according to an embodiment of the present application. DETAILED DESCRIPTION
[0031] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0032] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0033] According to one aspect of an embodiment of the present application, a flow control method is provided. The flow control method is widely used in smart home (Smart Home), smart home, smart home equipment ecology, smart residential (IntelligenceHouse) ecology and other whole-house intelligent digital control application scenarios. Optionally, in this embodiment, the above flow control method can be applied to Figure 1 In the hardware environment composed of the terminal device 102 and the server 104 shown in FIG. Figure 1 As shown, the server 104 is connected to the terminal device 102 via a network, and can be used to provide services (such as application services, etc.) for the terminal or a client installed on the terminal. A database can be set on the server or independently of the server to provide data storage services for the server 104. Cloud computing and / or edge computing services can be configured on the server or independently of the server to provide data computing services for the server 104.
[0034] The network may include but is not limited to at least one of the following: wired network, wireless network. The wired network may include but is not limited to at least one of the following: wide area network, metropolitan area network, local area network, and the wireless network may include but is not limited to at least one of the following: WIFI (Wireless Fidelity), Bluetooth. The terminal device 102 may be but is not limited to a PC, a mobile phone, a tablet computer, a smart air conditioner, a smart range hood, a smart refrigerator, a smart oven, a smart stove, a smart washing machine, a smart water heater, a smart washing device, a smart dishwasher, a smart projection device, a smart TV, a smart clothes drying rack, a smart curtain, a smart audio and video, a smart socket, a smart speaker, a smart fresh air device, a smart kitchen and bathroom device, a smart bathroom device, a smart sweeping robot, a smart window cleaning robot, a smart mopping robot, a smart air purification device, a smart steamer, a smart microwave oven, a smart kitchen treasure, a smart purifier, a smart water dispenser, a smart door lock, etc.
[0035] In order to solve the above problems, a flow control method is provided in this embodiment, including but not limited to being applied to the Sentinel flow protection framework. Figure 2 is a flow chart of a flow control method according to an embodiment of the present application, the process includes the following steps S202-S204:
[0036] Step S202: Obtain N parameter values from a parameter value set, wherein the parameter value set includes at least two of the following: the number of queries processed by the business unit in each time unit, the response time (ResponseTime, referred to as RT) of the business unit, the usage rate of the central processing unit (Central Processing Unit, referred to as CPU) of the target device running the business unit, the memory occupancy of the business unit, and the time node when the target device runs the business unit; N is an integer greater than or equal to 2;
[0037] It should be noted that the number of queries processed by a business unit in each time unit is the number of queries per second (QPS) of the business unit.
[0038] It should be noted that the business unit is used to run business services. To control the flow of a business unit is to control the flow of a business service.
[0039] Optionally, the business service is a microservice, which is a software architecture pattern that splits an application into small, independent, deployable services, each with its own business functions and data storage. These services collaborate with each other through lightweight communication mechanisms and can be deployed and expanded independently, thereby improving the maintainability, flexibility, and scalability of the system. The microservice architecture allows development teams to develop and deploy new features faster while reducing the complexity of the entire system. By splitting the application into small services, continuous integration and continuous deployment can be performed more easily, achieving the goal of rapid iteration and rapid response to customer needs.
[0040] Step S204: performing flow control on the service unit according to the N parameter values.
[0041] Optionally, the flow control includes: not limiting the flow of the business unit, limiting the flow of the business unit, fusing the business unit (ie, temporarily stopping access to the business unit), and downgrading the business unit.
[0042] The above steps control the flow of the service unit according to at least two parameters in the parameter value set, thereby solving the problem that the flow control framework cannot better control the flow of the service unit, and thus can better control the flow of the service unit.
[0043] In an exemplary embodiment, the above step S204 includes: step S11, or step S12, or step S11 and step S12, or step S11 and step S13, or step S12 and step S13, or step S11, step S12 and step S13:
[0044] Step S11: When the response time is greater than or equal to the first response time, flow control is performed on the service unit according to the CPU usage rate;
[0045] Optionally, the first response time is 1000ms.
[0046] Step S12: When the response time is greater than or equal to the second response time and less than the first response time, flow control is performed on the business unit according to the number of queries;
[0047] Optionally, the second response time is 20 ms.
[0048] Step S13: when the time response is less than the second response time, no flow limiting is performed on the service unit.
[0049] In an exemplary embodiment, the flow control of the service unit is performed according to the usage rate of the CPU, including the following steps S111-S112:
[0050] Step S111: when the CPU usage rate is less than the first usage rate, flow control is performed on the service unit according to the memory occupancy;
[0051] Optionally, the first usage rate is 90%.
[0052] Optionally, flow control is performed on the business unit according to the memory occupancy, including: when the memory occupancy is used to indicate that the size of the memory occupied by the business unit on the target device is greater than or equal to a first size, flow limiting is performed on the business unit; when the memory occupancy is used to indicate that the size of the memory occupied by the business unit on the target device is less than the first size, no flow limiting is performed on the business unit.
[0053] Optionally, the first size is 3G.
[0054] Step S112: When the CPU usage rate is greater than or equal to the first usage rate, flow control is performed on the service unit according to the time node.
[0055] Optionally, flow control is performed on the business unit according to the time node, including: when the time node is a stress test time node, no flow control is performed on the business unit; when the time node is not a stress test time node, flow control is performed on the business unit.
[0056] In an exemplary embodiment, performing flow control on the service unit according to the query times includes the following steps S121 and / or S122:
[0057] Step S121: When the query number is greater than or equal to the preset query number, flow control is performed on the service unit according to the time node;
[0058] Optionally, the preset query number is 20 times.
[0059] Step S122: when the query number is less than the preset query number, the service unit is not subject to flow restriction.
[0060] In an exemplary embodiment, performing flow control on the service unit according to the time node includes the following steps S21 and / or S22:
[0061] Step S21: when the time node is a stress test time node, not limiting the flow of the business unit;
[0062] It should be noted that since limiting the flow of a business unit will affect the stress test of the business unit, when the business unit is at a stress test time node, the flow limiting configuration is deleted in advance and the business unit is not limited.
[0063] Step S22: When the time node is not the stress test time node, flow control is performed on the business unit according to the CPU usage rate.
[0064] In an exemplary embodiment, the flow control of the service unit is performed according to the usage rate of the CPU, including the following steps S31-S32:
[0065] Step S31: when the time node is a preset time node, determining a preset usage rate corresponding to the preset time node;
[0066] Step S32: performing flow control on the service unit according to the relationship between the CPU usage rate and the preset usage rate.
[0067] Optionally, when the preset time node is an activity day node, determine a first preset usage rate corresponding to the activity day node; when the CPU usage rate is greater than or equal to the first preset usage rate, limit the flow of the business unit; when the CPU usage rate is less than the first preset usage rate, determine the memory usage of the business unit, and when the memory usage is used to indicate that the size of the memory occupied by the business unit on the target device is greater than or equal to a second size, limit the flow of the business unit; when the memory usage is used to indicate that the size of the memory occupied by the business unit on the target device is less than the second size, do not limit the flow of the business unit.
[0068] Optionally, the first preset usage rate is 99% and the second size is 4G.
[0069] Optionally, when the preset time node is an inactive day node, determine a second preset usage rate corresponding to the inactive day node; when the CPU usage rate is greater than or equal to the second preset usage rate, limit the flow of the business unit; when the CPU usage rate is less than the first preset usage rate, determine the memory usage of the business unit, and when the memory usage is used to indicate that the size of the memory occupied by the business unit on the target device is greater than or equal to a third size, limit the flow of the business unit; when the memory usage is used to indicate that the size of the memory occupied by the business unit on the target device is less than the second size, do not limit the flow of the business unit.
[0070] Optionally, the second preset usage rate is 80%, and the third size is 3G.
[0071] For a better understanding, the specific implementation of the above step S204 is described in detail. Figure 3 The flow control rules shown (in the form of a decision tree) are as follows: Figure 3 As shown in the figure, when the response time is abnormal, the flow protection will not be triggered directly, but the flow control will be carried out in combination with other rule nodes.
[0072] In an exemplary embodiment, before the above-mentioned step S202, the method further includes: in the case of monitoring that the traffic control rules are updated in the configuration center, obtaining the traffic control rules from the configuration center; wherein the traffic control rules are used to indicate obtaining the N parameter values from the parameter value set, and performing traffic control on the business unit according to the N parameter values.
[0073] For better understanding, Figure 4 As shown in the figure, users can modify the flow control rules in the configuration center through the console, and then the Sentinel flow protection framework obtains and loads the flow control rules from the configuration center when it detects that the flow control rules have been updated in the configuration center. It should be noted that a rule engine can be added to the core code of Sentinel to execute the obtained flow control rules (i.e. Figure 3 Decision tree shown).
[0074] It should be noted that this application is based on the sentinel traffic protection framework for optimization and transformation to make the traffic protection function more secure and reliable, solve the problem that the triggering condition of the flow control rule is single and cannot be matched and associated with other reference items, and solves the problem of cumbersome and complicated configuration of the flow control rules. When there are exception scenarios similar to stress testing, there is no need to reconfigure the rules.
[0075] It should be noted that the traffic control method can be applied to network traffic control, server load control, API access control, database access control, software license control, and mobile communication traffic control. In general, the traffic control method is suitable for scenarios where it is necessary to manage and restrict the use of various traffic.
[0076] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods of each embodiment of the present application.
[0077] In this embodiment, a flow control device is also provided, which is used to implement the above-mentioned embodiments and preferred embodiments, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceived.
[0078] Figure 5 : is a structural block diagram of a flow control device according to an embodiment of the present application, the device comprising:
[0079] The acquisition module 52 is used to acquire N parameter values from a parameter value set, wherein the parameter value set includes at least two of the following: the number of queries processed by the business unit in each time unit, the response time of the business unit, the usage rate of the central processing unit CPU of the target device running the business unit, the memory occupancy of the business unit, and the time node when the target device runs the business unit; N is an integer greater than or equal to 2;
[0080] The control module 54 is used to perform flow control on the service unit according to the N parameter values.
[0081] The above device controls the flow of the service unit according to at least two parameters in the parameter value set, thereby solving the problem that the flow control framework cannot better control the flow of the service unit, and can better control the flow of the service unit.
[0082] In an exemplary embodiment, the control module 54 is used to perform flow control on the business unit according to the N parameter values in the following manner: when the response time is greater than or equal to the first response time, the business unit is flow controlled according to the CPU usage rate; and / or when the response time is greater than or equal to the second response time and less than the first response time, the business unit is flow controlled according to the number of queries.
[0083] In an exemplary embodiment, the control module 54 is used to perform flow control on the business unit according to the CPU usage in the following manner: when the CPU usage is less than a first usage, performing flow control on the business unit according to the memory occupancy; when the CPU usage is greater than or equal to the first usage, performing flow control on the business unit according to the time node.
[0084] In an exemplary embodiment, the control module 54 is used to control the flow of the business unit according to the number of queries in the following manner: when the number of queries is greater than or equal to the preset number of queries, the flow of the business unit is controlled according to the time node; and / or when the number of queries is less than the preset number of queries, the flow of the business unit is not limited.
[0085] In an exemplary embodiment, the control module 54 is used to perform flow control on the business unit according to the time node in the following manner: when the time node is a stress test time node, no flow limiting is performed on the business unit; and / or when the time node is not the stress test time node, flow control is performed on the business unit according to the CPU usage rate.
[0086] In an exemplary embodiment, the control module 54 is used to perform flow control on the business unit according to the CPU usage rate in the following manner: when the time node is a preset time node, determine a preset usage rate corresponding to the preset time node; and perform flow control on the business unit according to the relationship between the CPU usage rate and the preset usage rate.
[0087] Optionally, when the preset time node is an activity day node, determine a first preset usage rate corresponding to the activity day node; when the CPU usage rate is greater than or equal to the first preset usage rate, limit the flow of the business unit; when the CPU usage rate is less than the first preset usage rate, determine the memory usage of the business unit, and when the memory usage is used to indicate that the size of the memory occupied by the business unit on the target device is greater than or equal to a second size, limit the flow of the business unit; when the memory usage is used to indicate that the size of the memory occupied by the business unit on the target device is less than the second size, do not limit the flow of the business unit.
[0088] Optionally, the first preset usage rate is 99% and the second size is 4G.
[0089] Optionally, when the preset time node is an inactive day node, determine a second preset usage rate corresponding to the inactive day node; when the CPU usage rate is greater than or equal to the second preset usage rate, limit the flow of the business unit; when the CPU usage rate is less than the first preset usage rate, determine the memory usage of the business unit, and when the memory usage is used to indicate that the size of the memory occupied by the business unit on the target device is greater than or equal to a third size, limit the flow of the business unit; when the memory usage is used to indicate that the size of the memory occupied by the business unit on the target device is less than the second size, do not limit the flow of the business unit.
[0090] In an exemplary embodiment, the acquisition module 52 is also used to obtain the traffic control rules from the configuration center before obtaining N parameter values from the parameter value set, upon monitoring that the traffic control rules are updated in the configuration center; wherein the traffic control rules are used to indicate that the N parameter values are obtained from the parameter value set, and traffic control is performed on the business unit based on the N parameter values.
[0091] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium includes a stored program, wherein the computer program is configured to execute the above-mentioned flow control method when running.
[0092] Optionally, in this embodiment, the storage medium may be configured to store a computer program for performing the following steps:
[0093] S1, obtaining N parameter values from a parameter value set, wherein the parameter value set includes at least two of the following: the number of queries processed by the business unit in each time unit, the response time of the business unit, the usage rate of the central processing unit CPU of the target device running the business unit, the memory occupancy of the business unit, and the time node when the target device runs the business unit; N is an integer greater than or equal to 2;
[0094] S2: Perform flow control on the service unit according to the N parameter values.
[0095] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0096] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.
[0097] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, wherein the processor is configured to execute the above-mentioned flow control method through the computer program.
[0098] Optionally, in this embodiment, the electronic device may be configured to perform the following steps through a computer program:
[0099] S1, obtaining N parameter values from a parameter value set, wherein the parameter value set includes at least two of the following: the number of queries processed by the business unit in each time unit, the response time of the business unit, the usage rate of the central processing unit CPU of the target device running the business unit, the memory occupancy of the business unit, and the time node when the target device runs the business unit; N is an integer greater than or equal to 2;
[0100] S2: Perform flow control on the service unit according to the N parameter values.
[0101] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0102] According to another aspect of the embodiments of the present application, a computer program product is provided, including a computer program, and the computer program performs the above-mentioned flow control method when executed by a processor.
[0103] Optionally, in this embodiment, the computer program product may be configured to perform the following steps through a computer program:
[0104] S1, obtaining N parameter values from a parameter value set, wherein the parameter value set includes at least two of the following: the number of queries processed by the business unit in each time unit, the response time of the business unit, the usage rate of the central processing unit CPU of the target device running the business unit, the memory occupancy of the business unit, and the time node when the target device runs the business unit; N is an integer greater than or equal to 2;
[0105] S2: Perform flow control on the service unit according to the N parameter values.
[0106] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.
[0107] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.
[0108] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A flow control method, characterized in that: include: Obtaining N parameter values from a parameter value set, wherein the parameter value set includes at least two of the following: the number of queries processed by the business unit in each time unit, the response time of the business unit, the usage rate of a central processing unit CPU of a target device running the business unit, the memory occupancy of the business unit, and the time node when the target device runs the business unit; N is an integer greater than or equal to 2; The traffic of the service unit is controlled according to the N parameter values.
2. The flow control method according to claim 1, characterized in that: The flow control of the service unit is performed according to the N parameter values, including: When the response time is greater than or equal to the first response time, performing flow control on the service unit according to the CPU usage rate; and / or When the response time is greater than or equal to the second response time and less than the first response time, flow control is performed on the service unit according to the number of queries.
3. The flow control method according to claim 2, characterized in that: The flow control of the service unit is performed according to the CPU usage, including: When the CPU usage rate is less than the first usage rate, flow control is performed on the service unit according to the memory occupancy; When the CPU usage rate is greater than or equal to the first usage rate, flow control is performed on the service unit according to the time node.
4. The flow control method according to claim 2, characterized in that: The flow control of the business unit is performed according to the query number, including: When the query number is greater than or equal to the preset query number, performing flow control on the service unit according to the time node; and / or When the query number is less than the preset query number, the service unit is not subject to flow limiting.
5. The flow control method according to claim 4, characterized in that: The flow control of the service unit is performed according to the time node, including: When the time node is a stress test time node, not limiting the flow of the business unit; and / or When the time node is not the stress test time node, flow control is performed on the business unit according to the utilization rate of the CPU.
6. The flow control method according to claim 5, characterized in that: The flow control of the service unit is performed according to the CPU usage, including: In the case where the time node is a preset time node, determining a preset usage rate corresponding to the preset time node; The traffic of the service unit is controlled according to the relationship between the CPU usage rate and the preset usage rate.
7. The flow control method according to claim 1, characterized in that: Before obtaining N parameter values from the parameter value set, the method further includes: In the case of monitoring that the flow control rule is updated in the configuration center, obtaining the flow control rule from the configuration center; The flow control rule is used to instruct to obtain the N parameter values from the parameter value set, and to perform flow control on the service unit according to the N parameter values.
8. A flow control device, characterized in that: include: an acquisition module, configured to acquire N parameter values from a parameter value set, wherein the parameter value set includes at least two of the following: the number of queries processed by the business unit in each time unit, the response time of the business unit, the usage rate of the central processing unit CPU of the target device running the business unit, the memory occupancy of the business unit, and the time node when the target device runs the business unit; N is an integer greater than or equal to 2; A control module is used to perform flow control on the service unit according to the N parameter values.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein the program executes the method according to any one of claims 1 to 7 when executed.
10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 7 through the computer program.
Citation Information
Patent Citations
Regulation method and device for container resources
CN108399100A
Flow control method and device, computer equipment and storage medium
CN110996352A
Flow control method and device, electronic equipment and storage medium
CN111262791A
Method and device for dynamically adjusting message receiving rate
CN113765813A
Multi-dimensional access flow control system
CN113765821A
