CN114827033A - Data flow control method, device, equipment and computer readable storage medium - Google Patents

Data flow control method, device, equipment and computer readable storage medium Download PDF

Info

Publication number
CN114827033A
CN114827033A CN202210392973.9A CN202210392973A CN114827033A CN 114827033 A CN114827033 A CN 114827033A CN 202210392973 A CN202210392973 A CN 202210392973A CN 114827033 A CN114827033 A CN 114827033A
Authority
CN
China
Prior art keywords
flow control
data
value
channel
data channel
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202210392973.9A
Other languages
Chinese (zh)
Other versions
CN114827033B (en
Inventor
王佶堃
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Migu Cultural Technology Co Ltd
China Mobile Communications Group Co Ltd
Original Assignee
Migu Cultural Technology Co Ltd
China Mobile Communications Group Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Migu Cultural Technology Co Ltd, China Mobile Communications Group Co Ltd filed Critical Migu Cultural Technology Co Ltd
Priority to CN202210392973.9A priority Critical patent/CN114827033B/en
Publication of CN114827033A publication Critical patent/CN114827033A/en
Application granted granted Critical
Publication of CN114827033B publication Critical patent/CN114827033B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5011Pool
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5018Thread allocation

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention discloses a data flow control method, a data flow control device, data flow control equipment and a computer readable storage medium, and belongs to the technical field of data pushing. The data flow control method comprises the following steps: collecting data backlog values of all data channels; calculating the flow control value of each data channel according to the data backlog value and the size of the message sending thread pool; and issuing data according to the flow control value of each data channel. According to the method and the device, the flow control value of each data channel is obtained through collecting the data backlog value of each data channel and calculating according to the data backlog value and the size of the message sending thread pool, namely the number of threads required by each data channel is obtained, data is issued according to the flow control value of each data channel, resources of the data sending thread pool are allocated, the production speed of each channel is dynamically controlled automatically, and the maximization of resource utilization is ensured.

Description

Data flow control method, device, equipment and computer readable storage medium
Technical Field
The present invention relates to the field of data push technologies, and in particular, to a data flow control method, apparatus, device, and computer readable storage medium.
Background
Data flow control of data streams has been a very critical technical problem in data transmission or exchange.
At present, a data flow control scheme of a push platform is generally implemented by a token bucket algorithm in the guava (single node) or the redis (distributed) of google, where a token bucket is a bucket storing tokens with a fixed capacity, the tokens are added into the bucket according to a fixed rate, and data push is performed only on a thread that takes the token. However, this method requires setting the capacity of the token bucket at initialization, lacks variability, and cannot flexibly allocate resources in the case of multiple channels, and thus has a problem of low resource allocation efficiency.
Disclosure of Invention
The invention mainly aims to provide a data flow control method, a data flow control device, data flow control equipment and a computer readable storage medium, and aims to solve the problem of how to improve the utilization rate of resources.
In order to achieve the above object, the present invention provides a data flow control method, which comprises the following steps:
collecting data backlog values of all data channels;
calculating the flow control value of each data channel according to the data backlog value and the size of the message sending thread pool;
and issuing data according to the flow control value of each data channel.
Optionally, the step of calculating a flow control value of each data channel according to the data backlog value and the size of the message sending thread pool includes:
acquiring a target proportion of each data channel; wherein the target ratio comprises: backlog weight proportion and/or abnormal request filtering proportion;
and calculating the flow control value of each data channel based on the target proportion, the data backlog value and the size of the message sending thread pool.
Optionally, the step of obtaining the abnormal request filtering ratio includes:
acquiring flow control triggering times, data acquisition time intervals and initialized flow control values of all data channels of a downstream system;
and calculating the abnormal request filtering proportion according to the flow control triggering times, the data acquisition time interval and the initialized flow control value of each data channel.
Optionally, the step of obtaining the flow control trigger times of the downstream system includes:
judging whether the operation index of the downstream system interface meets the flow control triggering condition;
if the flow control triggering condition is met, triggering flow control and counting once;
and counting the flow control triggering times within the preset time.
Optionally, the step of calculating the abnormal request filtering ratio according to the flow control trigger times, the data acquisition time interval, and the initialized flow control value of each data channel includes:
acquiring a flow control amplification ratio;
and calculating the downstream abnormal request filtering proportion based on the flow control amplification ratio, the flow control triggering times, the data acquisition time interval and the initialized flow control value of each data channel.
Optionally, after the step of calculating the flow control value of each data channel, the method further includes:
judging whether the flow control value of each data channel is lower than a preset threshold value or not;
and if the flow control value is lower than the preset threshold value, adjusting the flow control value of each data channel based on the preset threshold value.
Optionally, the step of issuing data according to the flow control value of each data channel includes:
according to a preset time interval, circularly executing the step of collecting the data backlog value of each data channel, and calculating the flow control value of each data channel according to the data backlog value and the size of the message sending thread pool;
and adjusting the thread allocation of the message sending thread pool according to the flow control value obtained by calculation of the preset time interval so as to issue data.
In addition, to achieve the above object, the present invention also provides a data stream control apparatus, including:
the channel acquisition module is used for acquiring data backlog values of all the data channels;
the flow control calculation module is used for calculating the flow control value of each data channel according to the data backlog value and the size of the message sending thread pool;
and the data issuing module is used for issuing data according to the flow control value of each data channel.
Optionally, the flow control calculation module is further configured to:
acquiring a target proportion of each data channel; wherein the target ratio comprises: backlog weight proportion and/or abnormal request filtering proportion;
and calculating the flow control value of each data channel based on the target proportion, the data backlog value and the size of the message sending thread pool.
Optionally, the flow control calculation module is further configured to:
acquiring flow control triggering times, data acquisition time intervals and initialized flow control values of all data channels of a downstream system;
and calculating the abnormal request filtering proportion according to the flow control triggering times, the data acquisition time interval and the initialized flow control value of each data channel.
Optionally, the flow control calculation module is further configured to:
judging whether the operation index of the downstream system interface meets the flow control triggering condition;
if the flow control triggering condition is met, triggering flow control and counting once;
and counting the flow control triggering times within the preset time.
Optionally, the flow control calculation module is further configured to:
acquiring a flow control amplification ratio;
and calculating the downstream abnormal request filtering proportion based on the flow control amplification ratio, the flow control triggering times, the data acquisition time interval and the initialized flow control value of each data channel.
Optionally, the flow control calculation module is further configured to:
judging whether the flow control value of each data channel is lower than a preset threshold value or not;
and if the flow control value is lower than the preset threshold value, adjusting the flow control value of each data channel based on the preset threshold value.
Optionally, the data issuing module is further configured to:
according to a preset time interval, circularly executing the step of collecting the data backlog value of each data channel, and calculating the flow control value of each data channel according to the data backlog value and the size of the message sending thread pool;
and adjusting the thread allocation of the message sending thread pool according to the flow control value obtained by calculation of the preset time interval so as to issue data.
In addition, to achieve the above object, the present invention also provides a data stream control apparatus, including: the data flow control method comprises a memory, a processor and a data flow control program stored on the memory and capable of running on the processor, wherein the data flow control program is configured to realize the steps of the data flow control method.
In addition, to achieve the above object, the present invention further provides a computer readable storage medium, which stores a data flow control program, and when the data flow control program is executed by a processor, the data flow control program implements the steps of the data flow control method as described above.
The data flow control method, the device, the equipment and the computer readable storage medium provided by the embodiment of the invention acquire the data backlog value of each data channel, calculate the flow control value of each data channel according to the data backlog value and the size of the message sending thread pool, namely obtain the thread number required by each data channel, and then send data according to the flow control value of each data channel to allocate the resources of the data sending thread pool, so that the production speed of each channel is automatically dynamically controlled, and the maximization of the resource utilization is ensured.
Drawings
Fig. 1 is a schematic structural diagram of a data flow control apparatus of a hardware operating environment according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating a data flow control method according to a first embodiment of the present invention;
FIG. 3 is a general flow chart of an embodiment of the data flow control method of the present invention;
FIG. 4 is a diagram illustrating a detailed procedure of calculating a flow control value according to a second embodiment of the data flow control method of the present invention;
fig. 5 is a detailed step diagram of acquiring flow control trigger times according to a third embodiment of the data flow control method of the present invention;
fig. 6 is a functional block diagram of a data flow control apparatus according to an embodiment of the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Referring to fig. 1, fig. 1 is a schematic structural diagram of a data flow control device in a hardware operating environment according to an embodiment of the present invention.
As shown in fig. 1, the data flow control apparatus may include: a processor 1001, such as a Central Processing Unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Wherein a communication bus 1002 is used to enable connective communication between these components. The user interface 1003 may include a Display screen (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a WIreless interface (e.g., a WIreless-FIdelity (WI-FI) interface). The Memory 1005 may be a Random Access Memory (RAM) Memory, or may be a Non-Volatile Memory (NVM), such as a disk Memory. The memory 1005 may alternatively be a storage device separate from the processor 1001.
Those skilled in the art will appreciate that the configuration shown in fig. 1 does not constitute a limitation of a data flow control apparatus and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components.
As shown in fig. 1, a memory 1005, which is a storage medium, may include an operating system, a data storage module, a network communication module, a user interface module, and a data flow control program therein.
In the data flow control apparatus shown in fig. 1, the network interface 1004 is mainly used for data communication with other apparatuses; the user interface 1003 is mainly used for data interaction with a user; the processor 1001 and the memory 1005 in the data flow control apparatus of the present invention may be disposed in the data flow control apparatus, and the data flow control apparatus invokes a data flow control program stored in the memory 1005 through the processor 1001 and executes the data flow control method provided in the embodiment of the present invention.
An embodiment of the present invention provides a data flow control method, and referring to fig. 2, fig. 2 is a schematic flow diagram of a first embodiment of the data flow control method according to the present invention.
In this embodiment, the data flow control method includes:
step S10, collecting data backlog values of each data channel;
step S20, calculating the flow control value of each data channel according to the data backlog value and the size of the message sending thread pool, wherein the flow control value is the thread number distributed to the data channel;
and step S30, issuing data according to the flow control value of each data channel.
The data flow control method of the embodiment may be applied to a data management device, a server, or a terminal, and is not limited herein. Firstly, explaining the flow control, namely flow control, mainly refers to controlling the concurrent flow of the thread so as to enable the concurrent flow not to exceed a flow control threshold. Because the data flow of the data flow is unpredictable, when a large amount of data suddenly flows to the server, the system is crowded and blocked, in order to enable the machine to continue to operate, a part of users are served as best as possible under the condition of not being down, the whole flow is ensured to continue, and in this time, the application needs to be subjected to flow control.
The data flow control method mainly aims at a specific application scene of multi-channel data control, when a data push request is received, data backlog values of all data channels are collected, flow control values are respectively calculated, the flow control values are thread allocation values, the redundancy of node resources can be judged by monitoring the use condition of a consumer thread pool, and appropriate resource adjustment is carried out.
The respective steps will be described in detail below:
step S10, collecting data backlog values of each data channel;
in one embodiment, data backlogs for each data channel are collected. It will be appreciated that flow control is typically bidirectional in that production is performed while consuming. Such as message pushing, content is pushed and consumed through an asynchronous queue, and the speed of downward production needs to be influenced when the data backlog amount changes. Therefore, the data backlog value of each data channel is first obtained.
Specifically, data backlog collection is usually implemented by middleware such as Kafka, RabbitMq, and the like, which is software providing general services and functions for applications. And acquiring the data backlog value of each channel per second through the shell script and storing the data backlog value in a memory of a consumer for flow control calculation. Kafka is a distributed publish-subscribe messaging system. In the related art, Kafka may send database data to consumers located downstream of Kafka for consumption processing. Taking kafka as an example, the channel data backlog value is calculated by commanding: the method comprises the steps of detecting data/kafka/bin/kafka-consumer-groups.sh-descriptor-bootstrap-server 192.128.1.1: 9092-group $ group-topic $ topic, writing the command into a shell script, calling the shell script regularly by using a crontab task in linux, and sending output data to an http interface of an application through a curl command to store the data into an application cache.
Step S20, calculating the flow control value of each data channel according to the data backlog value and the size of the message sending thread pool, wherein the flow control value is the thread number distributed to the data channel;
in one embodiment, the flow control value of each data channel is calculated according to the data backlog value and the size of the message sending thread pool. Referring to fig. 3, fig. 3 is a general flowchart of an embodiment of the data flow control method of the present invention, which is explained.
Setting the size of the message sending thread pool as k, setting the real-time data backlog values (corresponding to the backlog values of the acquisition channels in fig. 3) as b1, b2, and b3 (corresponding to channels c1, c2, and c3, respectively), setting the data acquisition time interval as T, setting the initialized flow control value of each channel as s, and setting the latest flow control value s1 of the c1 channel as:
Figure BDA0003597744530000071
and step S30, issuing data according to the flow control value of each data channel.
In an embodiment, a dynamic flow control value s is obtained according to a certain time interval, and data is issued according to the flow control value, that is, the speed limit for sending a thread pool to a consumer to release a task is performed. The issued data is a task request (data) received by each channel in the thread pool, and within the upper limit of the flow control value, the tasks received by each channel are distributed and issued through the thread pool, that is, the thread tasks are executed, for example, information push is performed on consumers. All nodes do not interfere with each other in a distribution system, the redundancy of the node resources can be judged by monitoring the use condition of a thread pool of a consumer, and appropriate resource adjustment is carried out.
In the embodiment, the flow control value of each data channel is calculated by collecting the data backlog value of each channel and according to the data backlog value and the size of the message sending thread pool, and then the resource allocation of each channel is adjusted according to the flow control value of each channel to issue data, so that the reasonable allocation of resources is ensured under the condition of multiple channels, and the efficiency and the stability of the system are improved.
Further, based on the first embodiment of the data flow control method of the present invention, a second embodiment of the data flow control method of the present invention is provided.
Referring to fig. 4, fig. 4 is a schematic diagram illustrating a refinement step of calculating a flow control value according to a second embodiment of the data flow control method of the present invention, where the difference between the second embodiment of the data flow control method of the present invention and the first embodiment of the data flow control method is that the step of calculating the flow control value of each data channel according to the data backlog value and the size of the message sending thread pool includes:
step S21, acquiring the target proportion of each data channel; wherein the target ratio comprises: backlog weight proportion and/or abnormal request filtering proportion;
step S22, calculating a flow control value of each data channel based on the target ratio, the data backlog value, and the message sending thread pool size.
In this embodiment, the flow control value may be calculated by a target ratio, a data backlog value, and a size of the message sending thread pool of each data channel, where the target ratio specifically includes: a backlog weight proportion and/or an exception request filter proportion.
Specifically, in an embodiment, the step of calculating the flow control value of each data channel according to the data backlog value and the size of the message sending thread pool includes:
step a, acquiring the backlog weight proportion of each data channel;
and b, calculating the flow control value of each data channel based on the backlog weight proportion, the data backlog value and the size of the message sending thread pool.
In this embodiment, the flow control value can be adjusted according to the service requirement by obtaining the backlog weight proportion of each data channel and using the backlog weight proportion and the backlog value of each data channel together to calculate the flow control value.
The respective steps will be described in detail below:
step a, acquiring the backlog weight proportion of each data channel;
in one embodiment, a backlog weight ratio for each data channel is obtained. It can be understood that, in practical application, each channel does not maintain the same capacity, and the flow rate of the individual channel can be increased according to actual requirements, so that the backlog weight proportion of each channel is obtained, that is, the number of threads to the individual channel is increased according to actual service requirements. Following the example of fig. 3, the channels c1, c2, and c3 correspond to a backlog weight ratio of a 1: a 2: a3. the backlog weight ratio of each channel may be determined according to specific service requirements, for example, according to the user quantity of each channel.
And b, calculating the flow control value of each data channel based on the backlog weight proportion, the data backlog value and the size of the message sending thread pool.
In this embodiment, after introducing the backlog weight ratio of each channel, that is, the flow control value s is affected by the ratio of the backlog values and the channel weight, at this time, the calculation formula of the c1 channel flow control value is as follows:
Figure BDA0003597744530000081
wherein, b1, b2 and b3 are data backlog values of all channels; k is the messaging thread pool size.
Further, in an embodiment, the step of calculating the flow control value of each data channel according to the data backlog value and the size of the message sending thread pool includes:
step c, acquiring an abnormal request filtering proportion;
and d, calculating the flow control value of each data channel based on the abnormal request filtering proportion, the data backlog value and the size of the message sending thread pool.
In this embodiment, in order to ensure the efficiency of the downstream request, filtering of the abnormal request is performed, the filtering proportion of the abnormal request of the downstream system is calculated by obtaining the flow control trigger times of the downstream system, the data acquisition time interval and the initial flow control value of each data channel, and then the flow control value is calculated according to the filtering proportion of the downstream abnormal request.
The respective steps will be described in detail below:
step c, acquiring an abnormal request filtering proportion;
the abnormal request filtering proportion is an abnormal request filtering proportion of a downstream system, and the step of obtaining the abnormal request filtering proportion comprises the following steps:
step c1, acquiring the flow control triggering times, the data acquisition time interval and the initialized flow control value of each data channel of the downstream system;
and c2, calculating the abnormal request filtering ratio according to the flow control triggering times, the data acquisition time interval and the initialized flow control value of each data channel.
In one embodiment, the flow control triggering times of the downstream system are counted, and the data acquisition time interval and the initialized flow control value of each data channel are obtained. Specifically, because the downstream flow control data is managed by the downstream system, when the data is sent to the downstream system through the http interface, the number of times of triggering flow control by the downstream system is recorded, statistics is performed according to a configurable time interval, and the result is stored in a memory of a consumer for flow control calculation.
Taking the message push channel as an example, at 8: 00, 12: 00, 14: 00, 17: 00 is the peak period of message pushing, the pushing platform will perform flow control on the whole network, the interface qps will drop from 3000 to 1000, the message sending flow transmitted to the upstream is embodied in that the return status code of the message pushing http interface is 503 (the server is not accessible), and the number of times of collecting and triggering the return code of 503 according to the time interval is the downstream flow control triggering number.
The data acquisition time interval refers to the time interval for acquiring data required for calculating the flow control value, the initialized flow control value of each data channel refers to the initial thread value allocated to each channel, and the data acquisition time interval and the initialized flow control value are preset. E represents a downstream abnormal request proportion filtering formula, and the filtering ratio of the abnormal requests or the normal request ratio is obtained through calculation, wherein the formula is as follows:
e=1-t1/(s*T)
the formula calculates normal data values in the time period of s × T. The sampling rate (time interval) is T, the initial flow control value (initial data channel thread allocation number) is s, s (initial flow control value) × T (time interval) × the number of flow control times that the channel allows to trigger (channel-processable thread number), and T1 is the number of flow control triggers. Then the ratio of no trigger flow control is determined by subtracting T1/(s × T) from 1.
And d, calculating the flow control value of each data channel based on the abnormal request filtering proportion, the data backlog value and the size of the message sending thread pool.
In one embodiment, the flow control value of each channel is calculated according to the downstream abnormal request filtering proportion and the data backlog value. Following the above example, taking the c1 channel as an example, the flow control value s1 is calculated as follows:
Figure BDA0003597744530000101
further, in an embodiment, the filtering of the abnormal request may be performed on the basis of the backlog weight ratio, and the amplification optimization may still be performed, that is, the step of calculating the flow control value of each data channel according to the data backlog value and the size of the message sending thread pool includes:
step e, acquiring the backlog weight proportion and the abnormal request filtering proportion of each data channel;
and f, calculating the flow control value of each data channel based on the backlog weight proportion, the abnormal request filtering proportion, the data backlog value and the size of the message sending thread pool.
Following the above example, at this time, the calculation formula is as follows:
Figure BDA0003597744530000102
further, in an embodiment, the step of calculating the abnormal request filtering ratio according to the flow control trigger times, the data acquisition time interval, and the initialized flow control value of each data channel includes:
step S23, obtaining the flow control amplification ratio;
and step S24, calculating the downstream abnormal request filtering proportion based on the flow control amplification ratio, the flow control triggering times, the data acquisition time interval and the initialized flow control value of each data channel.
In the embodiment, the abnormal request filtering proportion is calculated by obtaining the flow control amplification ratio, so that the amplification optimization of the flow control value can be realized, that is, the downstream flow control is triggered at a certain ratio within the allowable range of the downstream system, and the data is ensured to be transmitted in the maximum flow manner.
The respective steps will be explained below:
step S23, obtaining the flow control amplification ratio;
in one embodiment, a fluidic amplification ratio is obtained. The flow control amplification ratio is a threshold value, and specifically, an empirical value obtained by a test. That is, under the condition that the flow control is not triggered, the upward exploration is tried, the capacity is expanded a little, and if the flow control is triggered after the capacity expansion, the flow control amplification ratio is properly adjusted.
Specifically, the normal range is obtained by 1-T1/(s × T), and the expansion is performed by adding the flow control amplification ratio m, that is, without triggering the flow control. It should be noted that the flow control amplification ratio is an empirical value, and if the expansion is found and then the flow control is triggered, the flow control amplification ratio is reset, and repeated experiments are performed at the amplification ratio to determine whether the flow control value is reasonable or not, so as to confirm the flow control amplification ratio.
And step S24, calculating the downstream abnormal request filtering ratio based on the flow control amplification ratio, the flow control triggering times, the data acquisition time interval and the initialized flow control value of each data channel.
In one embodiment, the flow control value of each channel is calculated according to a preset flow control amplification ratio, a calculated downstream abnormal request filtering ratio, a collected data backlog value and a message sending thread pool size. The method optimizes the flow control upper limit judgment mode when a downstream system is requested, and improves the resource utilization rate. After the flow control amplification ratio m is obtained, the calculation formula of the abnormal request filtering proportion e is as follows:
Figure BDA0003597744530000111
here, the data actually used in the application are exemplified:
assuming that the message push channels are divided into apple c1, Hua is c2 and millet c3, the backlog weight ratio is set to be 3 according to the system user quantity of each channel: 1: 1, the basic logic is that according to the user quantity proportion, the ratio is 3: 1: 1 is set. The data backlog values of the channels are b 1-10W, b 2-4W, and b 3-1W, respectively. The downstream flow control data acquisition time interval T is 5s, the current flow control trigger times c1 is 20, c2 is 1000, c3 is 200, the initial flow control value of each data channel is 300, the size of the message sending thread pool is 1000, the flow control amplification ratio of the c1 channel is 1%, and the others are 0. Then the latest flow control value of each data channel is respectively:
Figure BDA0003597744530000112
Figure BDA0003597744530000113
Figure BDA0003597744530000114
the flow control value is the thread allocation value, and it can be seen that most threads push c1, i.e. apple messages, to the user (from 300 to 847) with the influence of the flow control trigger times and backlog data. Dynamic resource translation can be realized through 5s of calculation, and the message pushing speed is improved to a stable and efficient level.
In the embodiment, by setting the target proportion, specifically, by setting the backlog weight proportion and/or the abnormal request filtering proportion, the calculation of the flow control value is influenced by the data channel backlog weight proportion and the data backlog value, meanwhile, in order to ensure the efficiency of the downstream request, the abnormal request is further filtered, and by calculating the filtering proportion of the downstream abnormal request and setting the flow control amplification ratio, the upstream and downstream data parameters are reasonably utilized to perform flow control management, so that the rationality of resource allocation is ensured.
Further, based on the foregoing embodiment of the data flow control method of the present invention, a third embodiment of the data flow control method of the present invention is provided.
Referring to fig. 5, fig. 5 is a schematic diagram of a detailed step of acquiring the flow control trigger times according to the third embodiment of the data flow control method of the present invention, where the difference between the third embodiment of the data flow control method of the present invention and the previous embodiment of the data flow control method is that the step of acquiring the flow control trigger times of the downstream system includes:
step S25, judging whether the operation index of the downstream system interface meets the flow control triggering condition;
step S26, if yes, triggering flow control and counting once;
and step S27, counting the flow control triggering times within the preset time.
In this embodiment, the flow control triggering times of the downstream system are obtained by acquiring the operation index of the downstream system interface, determining whether the flow control triggering condition is met, triggering the flow control if the flow control triggering condition is met, counting once, and counting the number of times of triggering the flow control within a preset time.
The respective steps will be described in detail below:
step S25, judging whether the operation index of the downstream system interface meets the flow control triggering condition;
in one embodiment, when data is sent to a downstream system through an http interface, flow control triggering and counting can be performed by acquiring an operation index of the downstream system and judging whether the operation index meets a flow control triggering condition. The running index may be RT (average response time), QPS (query rate per second), TPS (number of transactions processed per second), etc. Specifically, the flow control trigger condition may be set according to an actual pressure test result, for example: the operation index is RT, the response time of a single request exceeds a threshold value, flow control is triggered, or the response time of a single request exceeds the threshold value, then 5 continuous request response times in the next 1s are detected, and if the response time exceeds the threshold value, flow control is triggered.
The flow control trigger may also be obtained by calculating an abnormal ratio: and triggering flow control when the request number is more than 5 in one second and the proportion of the abnormal request number in the total request number is more than the abnormal proportion.
In addition, the determination can be made by the iso-constants: and if the number of abnormal requests in one minute is greater than the set abnormal constant, triggering flow control.
Specifically, the flow control trigger condition may be obtained by simulating a pressure test on the system by multiple users using a pressure test tool, and determining that the average response time of the test exceeds a certain value, which is considered to be unacceptable.
Step S26, if yes, triggering flow control and counting once;
in one embodiment, flow control is triggered if the operation index of the downstream system meets a flow control trigger condition. Specifically, assuming that the operation index is QPS, it is determined whether the query rate per second of the downstream system interface is lower than a preset threshold, and if the query rate per second is lower than the preset threshold, it is recorded as triggering flow control once.
And step S27, counting the flow control triggering times within the preset time.
In an embodiment, the number of times of triggering the flow control within a certain time is obtained, and the number of times of triggering the flow control is counted. The preset time may be a calculation time interval of the flow control value, for example, when the flow control value is calculated every 5 seconds, the flow control trigger times within 5 seconds are counted correspondingly.
In the previous embodiment, the flow control trigger times can be obtained by acquiring the error return code, and the active trigger condition is set in the present embodiment, so that when the operation index of the downstream system cannot meet the set normal condition, that is, the flow control trigger condition is met, the flow control is triggered, and the flow control trigger times are obtained by counting.
Further, after the step of calculating the flow control value of each data channel, the method further includes:
step g, judging whether the flow control value of each data channel is lower than a preset threshold value;
and h, if the flow control value is lower than the preset threshold value, adjusting the flow control value of each data channel based on the preset threshold value.
In an embodiment, after the flow control value of each data channel is obtained through calculation, whether the flow control value of each data channel is lower than a preset threshold value is judged. It should be noted that, here, the flow control value of each data channel and the corresponding preset threshold are compared to obtain a comparison result between the flow control values of all the data channels and the preset threshold.
In this embodiment, the minimum thread number of each data channel is limited, and it can be understood that if the number of data channel allocation threads is too small, the flow control is easily triggered. Assuming that the size of the thread pool is 1000, at this time, the flow control value of the channel 1 is 800, the flow control value of the channel 2 is 60, and the flow control value of the channel 3 is 40, although it is a better solution to directly perform thread allocation according to the flow control value, the present embodiment further considers the user amount or the actual demand of each data channel. Assuming that the average flow control value of the channel 3 is 100 and the flow control value calculated in this time interval is 40, the allocation is normally performed directly according to 40, but this time may be due to a data volume peak and valley, or a temporary data channel receiving thread has a problem, which is a possibility that a large amount of data volume suddenly appears before the flow control value in the next time interval is calculated, and thus a problem of untimely adjustment is likely to occur. Therefore, in order to better implement dynamic adjustment of resource allocation, a flow control threshold may be set for each data channel, and if the flow control value calculated by one or more channels is lower than the preset threshold, the flow control value of the data channel lower than the preset threshold may be set as the preset threshold under the condition that normal operation of the data channel whose other flow control value is not lower than the preset threshold is not affected, and then flow control values of the remaining channels are adaptively adjusted. In the above example, the flow control value of the channel 3 may be set to 100 directly; as another example, assuming that the size of the thread pool is 1000, the flow control value of the channel 1 is 860, the channel 2 is 60, the channel 3 is 40, and the channel 3 is lower than the preset threshold 100, and on the premise that the number of threads is not exceeded and the flow control values of the remaining data channels not lower than the preset threshold are not changed, the flow control value of the channel 3 is set to 80, which is more helpful for the stability of the overall system.
Further, in an embodiment, the step of issuing data according to the flow control value of each data channel includes:
step S31, according to a preset time interval, circularly executing the steps of collecting the data backlog value of each data channel, counting the flow control triggering times of a downstream system within a preset time, and calculating the flow control value of each data channel according to the data backlog value and the flow control triggering times;
and step S32, adjusting the thread allocation of the message sending thread pool according to the flow control value calculated by the preset time interval to issue data.
In this embodiment, data acquisition is performed according to a preset time interval, a flow control value of each data channel is calculated, and thread pool allocation is dynamically adjusted according to the flow control value obtained by calculation, so as to issue data. Specifically, after the flow control value of each data channel is calculated, the flow control values are allocated, and the above example is used: the initial flow control values of the three channels c1, c2 and c3 are 300, and after the flow control values of the three data channels are calculated (s1 is 847, s2 is 37 and s3 is 24), the flow control values of the three channels are correspondingly adjusted instead of being distributed according to the initial flow control values, 847 threads in the thread pool are distributed to the channel c1, 37 threads are distributed to c2, and 24 threads are distributed to c 3. The trigger function of collecting statistics according to a preset time interval can be realized by a timer and executed by adopting an independent thread pool. The predetermined time interval may be set according to actual requirements, for example, data acquisition is performed every 10 seconds or every 15 seconds.
In the embodiment, the flow control triggering times are obtained by acquiring the operation index of the downstream system interface and judging whether the operation index meets the flow control triggering condition; and after the step of calculating the flow control value of each data channel, judging whether the flow control value is lower than a preset threshold value, if so, adjusting the flow control value of each data channel according to the preset threshold value, thereby ensuring the lowest accessible flow of each data channel. Further, according to a preset time interval, the steps of collecting the data backlog value of each data channel and calculating the flow control value of each data channel according to the data backlog value and the size of the message sending thread pool are executed in a circulating mode, and the message sending thread pool is adjusted to be distributed for data issuing according to the flow control value obtained through calculation of the preset time interval, so that the flexible request is realized, and the resource utilization rate is improved.
The invention also provides a data flow control device. As shown in fig. 6, fig. 6 is a functional module schematic diagram of a data flow control apparatus according to an embodiment of the present invention. The device comprises:
the channel acquisition module 10 is used for acquiring data backlog values of all data channels;
the flow control calculation module 20 is configured to calculate a flow control value of each data channel according to the data backlog value and the size of the message sending thread pool;
and the data issuing module 30 is configured to issue data according to the flow control value of each data channel.
Optionally, the flow control calculation module is further configured to:
acquiring a target proportion of each data channel; wherein the target ratio comprises: backlog weight proportion and/or abnormal request filtering proportion;
and calculating the flow control value of each data channel based on the target proportion, the data backlog value and the size of the message sending thread pool.
Optionally, the flow control calculation module is further configured to:
and acquiring the flow control triggering times, the data acquisition time interval and the initialized flow control value of each data channel of the downstream system, and calculating the abnormal request filtering proportion.
Optionally, the flow control calculation module is further configured to:
judging whether the operation index of the downstream system interface meets the flow control triggering condition;
if the flow control triggering condition is met, triggering the flow control and counting once;
and counting the flow control triggering times within the preset time.
Optionally, the flow control calculation module is further configured to:
acquiring a flow control amplification ratio;
and calculating the downstream abnormal request filtering proportion based on the flow control amplification ratio, the flow control triggering times, the data acquisition time interval and the initialized flow control value of each data channel.
Optionally, the flow control calculation module is further configured to:
judging whether the flow control value of each data channel is lower than a preset threshold value or not;
and if the flow control value is lower than the preset threshold value, adjusting the flow control value of each data channel based on the preset threshold value.
Optionally, the data issuing module is further configured to:
according to a preset time interval, circularly executing the step of collecting the data backlog value of each data channel, and calculating the flow control value of each data channel according to the data backlog value and the size of the message sending thread pool;
and adjusting the thread allocation of the message sending thread pool according to the flow control value obtained by calculation of the preset time interval so as to issue data.
The invention also provides a computer readable storage medium.
The computer readable storage medium of the present invention stores a data flow control program, and the data flow control program, when executed by a processor, implements the steps of the data flow control method as described above.
The method implemented when the data flow control program running on the processor is executed may refer to each embodiment of the data flow control method of the present invention, and details are not described here.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) as described above and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (10)

1. A data flow control method, characterized in that the data flow control method comprises the steps of:
collecting data backlog values of all data channels;
calculating a flow control value of each data channel according to the data backlog value and the size of the message sending thread pool, wherein the flow control value is the thread number distributed to the data channel;
and issuing data according to the flow control value of each data channel.
2. The data flow control method according to claim 1, wherein the step of calculating the flow control value of each data channel according to the data backlog value and the size of the message sending thread pool comprises:
acquiring a target proportion of each data channel; wherein the target ratio comprises: backlog weight proportion and/or abnormal request filtering proportion;
and calculating the flow control value of each data channel based on the target proportion, the data backlog value and the size of the message sending thread pool.
3. The data flow control method according to claim 2, wherein the step of obtaining the abnormal request filtering ratio comprises:
acquiring flow control triggering times, data acquisition time intervals and initialized flow control values of all data channels of a downstream system;
and calculating the abnormal request filtering proportion according to the flow control triggering times, the data acquisition time interval and the initialized flow control value of each data channel.
4. The data flow control method according to claim 3, wherein the step of obtaining the flow control trigger times of the downstream system comprises:
judging whether the operation index of the downstream system meets a flow control triggering condition;
if the flow control triggering condition is met, triggering flow control and counting once;
and counting the flow control triggering times within the preset time.
5. The data flow control method according to claim 3, wherein the step of calculating the abnormal request filtering ratio according to the flow control trigger times, the data acquisition time interval, and the initialized flow control value of each data channel comprises:
acquiring a flow control amplification ratio;
and calculating the downstream abnormal request filtering proportion based on the flow control amplification ratio, the flow control triggering times, the data acquisition time interval and the initialized flow control value of each data channel.
6. The data flow control method of claim 1, wherein after the step of calculating the flow control value for each data channel, the method further comprises:
judging whether the flow control value of each data channel is lower than a corresponding preset threshold value or not;
and if the flow control value is lower than the preset threshold value, adjusting the flow control value of each data channel based on the preset threshold value.
7. The data flow control method according to any one of claims 1 to 6, wherein the step of issuing data according to the flow control value of each data channel includes:
according to a preset time interval, circularly executing the step of collecting the data backlog value of each data channel, and calculating the flow control value of each data channel according to the data backlog value and the size of the message sending thread pool;
and adjusting the thread allocation of the message sending thread pool according to the flow control value obtained by calculation of the preset time interval so as to issue data.
8. A data flow control apparatus, the apparatus comprising:
the channel acquisition module is used for acquiring data backlog values of all the data channels;
the flow control calculation module is used for calculating the flow control value of each data channel according to the data backlog value and the size of the message sending thread pool;
and the data issuing module is used for issuing data according to the flow control value of each data channel.
9. A data flow control apparatus, characterized in that the apparatus comprises: a memory, a processor, and a data flow control program stored on the memory and executable on the processor, the data flow control program configured to implement the steps of the data flow control method of any one of claims 1 to 7.
10. A computer-readable storage medium, on which a data flow control program is stored, which when executed by a processor implements the steps of the data flow control method according to any one of claims 1 to 7.
CN202210392973.9A 2022-04-15 2022-04-15 Data flow control method, device, equipment and computer readable storage medium Active CN114827033B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210392973.9A CN114827033B (en) 2022-04-15 2022-04-15 Data flow control method, device, equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210392973.9A CN114827033B (en) 2022-04-15 2022-04-15 Data flow control method, device, equipment and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN114827033A true CN114827033A (en) 2022-07-29
CN114827033B CN114827033B (en) 2024-04-19

Family

ID=82536505

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210392973.9A Active CN114827033B (en) 2022-04-15 2022-04-15 Data flow control method, device, equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN114827033B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115378849A (en) * 2022-08-24 2022-11-22 成都新希望金融信息有限公司 Flow real-time monitoring method and device, electronic equipment and readable storage medium

Citations (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103259738A (en) * 2013-04-27 2013-08-21 华为技术有限公司 Data transmission method, data generator and initiative flow control system
US20150186489A1 (en) * 2013-12-27 2015-07-02 Oracle International Corporation System and method for supporting asynchronous invocation in a distributed data grid
EP3079314A1 (en) * 2015-04-08 2016-10-12 Alcatel Lucent Method to manage resources, system and computer-readable medium
CN108694107A (en) * 2017-04-10 2018-10-23 北京京东尚科信息技术有限公司 Backlog monitoring method, device, readable medium and the electronic equipment of message queue
CN109582455A (en) * 2018-12-03 2019-04-05 恒生电子股份有限公司 Multithreading task processing method, device and storage medium
CN110166367A (en) * 2018-02-14 2019-08-23 华为技术有限公司 The method and device of flow is controlled in a kind of packet network
WO2019205371A1 (en) * 2018-04-24 2019-10-31 平安科技(深圳)有限公司 Server, message allocation method, and storage medium
CN110996352A (en) * 2019-12-20 2020-04-10 众安在线财产保险股份有限公司 Flow control method and device, computer equipment and storage medium
CN111290908A (en) * 2020-01-15 2020-06-16 四川万益能源科技有限公司 Kafka data consumption backlog condition monitoring and alarming method
CN111770002A (en) * 2020-06-12 2020-10-13 南京领行科技股份有限公司 Test data forwarding control method and device, readable storage medium and electronic equipment
CN112612607A (en) * 2020-12-16 2021-04-06 平安消费金融有限公司 Data processing method, device, computer equipment and medium based on message queue
BR102020019649A2 (en) * 2019-12-27 2021-06-29 Intel Corporation apparatus and method for adaptively scheduling work on heterogeneous processing resources
CN113419852A (en) * 2021-06-22 2021-09-21 康键信息技术(深圳)有限公司 Request response method, device, equipment and storage medium of microservice
WO2021197331A1 (en) * 2020-03-30 2021-10-07 维沃移动通信有限公司 Method and device for transmitting flow control message
CN113687928A (en) * 2021-08-03 2021-11-23 广州华多网络科技有限公司 Message scheduling control method and corresponding device, equipment and medium thereof
WO2022012054A1 (en) * 2020-07-17 2022-01-20 苏州浪潮智能科技有限公司 Method, system and device for dynamically preventing traffic attacks, and storage medium

Patent Citations (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103259738A (en) * 2013-04-27 2013-08-21 华为技术有限公司 Data transmission method, data generator and initiative flow control system
US20150186489A1 (en) * 2013-12-27 2015-07-02 Oracle International Corporation System and method for supporting asynchronous invocation in a distributed data grid
EP3079314A1 (en) * 2015-04-08 2016-10-12 Alcatel Lucent Method to manage resources, system and computer-readable medium
CN108694107A (en) * 2017-04-10 2018-10-23 北京京东尚科信息技术有限公司 Backlog monitoring method, device, readable medium and the electronic equipment of message queue
CN110166367A (en) * 2018-02-14 2019-08-23 华为技术有限公司 The method and device of flow is controlled in a kind of packet network
WO2019205371A1 (en) * 2018-04-24 2019-10-31 平安科技(深圳)有限公司 Server, message allocation method, and storage medium
CN109582455A (en) * 2018-12-03 2019-04-05 恒生电子股份有限公司 Multithreading task processing method, device and storage medium
CN110996352A (en) * 2019-12-20 2020-04-10 众安在线财产保险股份有限公司 Flow control method and device, computer equipment and storage medium
BR102020019649A2 (en) * 2019-12-27 2021-06-29 Intel Corporation apparatus and method for adaptively scheduling work on heterogeneous processing resources
CN111290908A (en) * 2020-01-15 2020-06-16 四川万益能源科技有限公司 Kafka data consumption backlog condition monitoring and alarming method
WO2021197331A1 (en) * 2020-03-30 2021-10-07 维沃移动通信有限公司 Method and device for transmitting flow control message
CN111770002A (en) * 2020-06-12 2020-10-13 南京领行科技股份有限公司 Test data forwarding control method and device, readable storage medium and electronic equipment
WO2022012054A1 (en) * 2020-07-17 2022-01-20 苏州浪潮智能科技有限公司 Method, system and device for dynamically preventing traffic attacks, and storage medium
CN112612607A (en) * 2020-12-16 2021-04-06 平安消费金融有限公司 Data processing method, device, computer equipment and medium based on message queue
CN113419852A (en) * 2021-06-22 2021-09-21 康键信息技术(深圳)有限公司 Request response method, device, equipment and storage medium of microservice
CN113687928A (en) * 2021-08-03 2021-11-23 广州华多网络科技有限公司 Message scheduling control method and corresponding device, equipment and medium thereof

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115378849A (en) * 2022-08-24 2022-11-22 成都新希望金融信息有限公司 Flow real-time monitoring method and device, electronic equipment and readable storage medium
CN115378849B (en) * 2022-08-24 2023-06-23 成都新希望金融信息有限公司 Flow real-time monitoring method and device, electronic equipment and readable storage medium

Also Published As

Publication number Publication date
CN114827033B (en) 2024-04-19

Similar Documents

Publication Publication Date Title
CN110995614B (en) Computing power resource allocation method and device
WO2018130163A1 (en) Scheduling method and device for mobile cloud computing platform
CN106557369B (en) Multithreading management method and system
US8547840B1 (en) Bandwidth allocation of bursty signals
US20150295970A1 (en) Method and device for augmenting and releasing capacity of computing resources in real-time stream computing system
CN103699445A (en) Task scheduling method, device and system
CN111277640B (en) User request processing method, device, system, computer equipment and storage medium
CN107171839A (en) A kind of bandwidth traffic cost control method
CN111131401A (en) Service request response method and system
CN106936867B (en) Service request response method and device
CN112988390A (en) Calculation power resource allocation method and device
CN113296929A (en) Resource matching method, device and system based on cloud computing
CN111813543A (en) Adaptive scheduling method, device and computer readable storage medium
CN114827033A (en) Data flow control method, device, equipment and computer readable storage medium
CN115277577A (en) Data processing method, data processing device, computer equipment and computer readable storage medium
CN112463315A (en) Cluster task scheduling method and device and related components
CN114501351A (en) Flow control method, flow control equipment and storage medium
CN114003377A (en) Memory fusing method, device, equipment and readable medium based on ES service
CN105242955B (en) A kind of magnetic disk of virtual machine input/output scheduling method and system
EP3916554A1 (en) A throughput-optimized, quality-of-service aware power capping system
CN113079062B (en) Resource adjusting method and device, computer equipment and storage medium
CN111897659B (en) Method, system and device for controlling service processing frequency and electronic equipment
CN102137091A (en) Overload control method, device and system as well as client-side
CN111966918A (en) Current limiting method, device and system for concurrent access requests
CN111143071A (en) Cache partition management method, system and related components based on MCS system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant