CN114827033B - 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
CN114827033B
CN114827033B CN202210392973.9A CN202210392973A CN114827033B CN 114827033 B CN114827033 B CN 114827033B CN 202210392973 A CN202210392973 A CN 202210392973A CN 114827033 B CN114827033 B CN 114827033B
Authority
CN
China
Prior art keywords
flow control
data
value
data channel
backlog
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.)
Active
Application number
CN202210392973.9A
Other languages
Chinese (zh)
Other versions
CN114827033A (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.)
China Mobile Communications Group Co Ltd
MIGU Culture Technology Co Ltd
Original Assignee
China Mobile Communications Group Co Ltd
MIGU Culture Technology 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 China Mobile Communications Group Co Ltd, MIGU Culture Technology Co Ltd filed Critical China Mobile Communications Group 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

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 of the invention 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 invention, the flow control value of each data channel is obtained through calculation according to the data backlog value and the size of the message sending thread pool by collecting the data backlog value of each data channel, namely the number of threads required by each data channel is obtained, and then data is issued according to the flow control value of each data channel, so that the resources of the data sending thread pool are allocated, the dynamic speed control of the production speed of each channel is automatically realized, and the maximization of the 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 pushing technologies, and in particular, to a data flow control method, device, equipment, and computer readable storage medium.
Background
In data transmission or exchange, data flow control of data streams has been a very critical technical problem.
Currently, the data flow control scheme of the push platform is generally implemented by a token bucket algorithm in guava (single node) or redis (distributed) of google, wherein the token bucket is a bucket for storing tokens with fixed capacity, the tokens are added into the bucket according to a fixed speed, and only a thread taking the tokens can push data. However, this method needs to set the capacity of the token bucket at the time of initialization, lacks variability, and cannot flexibly allocate resources in the case of multiple channels, so that there is a problem of low efficiency of resource allocation.
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 includes 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 the flow control value of each data channel according to the data backlog value and the size of the messaging thread pool includes:
obtaining the target proportion of each data channel; wherein the target ratio comprises: backlog weight ratio and/or abnormal request filtering ratio;
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 proportion includes:
acquiring the flow control triggering times, the data acquisition time interval and the initialization flow control value of each data channel 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 initialization 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 or not;
If the flow control triggering condition is met, triggering flow control and counting once;
Counting the flow control triggering times in a 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:
Obtaining a flow control amplification ratio;
And calculating the downstream abnormal request filtering proportion based on the flow control amplification ratio, the flow control trigger 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;
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:
circularly executing the step of collecting the data backlog value of each data channel according to a preset time interval, and calculating the flow control value of each data channel according to the data backlog value and the size of a message sending thread pool;
And adjusting the thread allocation of the message sending thread pool according to the flow control value obtained by calculation at the preset time interval so as to carry out data issuing.
In addition, to achieve the above object, the present invention further provides a data flow control device, including:
the channel acquisition module is used for acquiring the data backlog value of each data channel;
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:
obtaining the target proportion of each data channel; wherein the target ratio comprises: backlog weight ratio and/or abnormal request filtering ratio;
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 the flow control triggering times, the data acquisition time interval and the initialization flow control value of each data channel 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 initialization 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 or not;
If the flow control triggering condition is met, triggering flow control and counting once;
Counting the flow control triggering times in a preset time.
Optionally, the flow control calculation module is further configured to:
Obtaining a flow control amplification ratio;
And calculating the downstream abnormal request filtering proportion based on the flow control amplification ratio, the flow control trigger 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;
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:
circularly executing the step of collecting the data backlog value of each data channel according to a preset time interval, and calculating the flow control value of each data channel according to the data backlog value and the size of a message sending thread pool;
And adjusting the thread allocation of the message sending thread pool according to the flow control value obtained by calculation at the preset time interval so as to carry out data issuing.
In addition, to achieve the above object, the present invention further provides a data flow control device, including: 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 as described above.
In addition, to achieve the above object, the present invention also provides a computer-readable storage medium having stored thereon a data flow control program which, when executed by a processor, implements the steps of the data flow control method as described above.
According to the data flow control method, the device, the equipment and the computer readable storage medium, the flow control value of each data channel is obtained through calculation according to the data backlog value and the size of the message sending thread pool by collecting the data backlog value of each data channel, namely the number of threads required by each data channel is obtained, and then data is issued according to the flow control value of each data channel, so that resources of the data sending thread pool are allocated, dynamic speed control of the production speed of each channel is achieved, and the maximum utilization of the resources is ensured.
Drawings
FIG. 1 is a schematic diagram of a data flow control device of a hardware operating environment according to an embodiment of the present invention;
Fig. 2 is a schematic flow chart of a first embodiment of a data flow control method according to 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 schematic diagram of a refinement step 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 schematic diagram of a refinement step for obtaining the number of flow control triggers according to a third embodiment of the data flow control method of the present invention;
fig. 6 is a schematic diagram of functional modules of an embodiment of the data flow control device of the present invention.
The achievement of the objects, functional features and advantages of the present invention will be further described with reference to the accompanying drawings, in conjunction with the embodiments.
Detailed Description
It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
Referring to fig. 1, fig. 1 is a schematic diagram of a data flow control device of a hardware running environment according to an embodiment of the present invention.
As shown in fig. 1, the data flow control device may include: a processor 1001, such as a central processing unit (Central Processing Unit, CPU), a communication bus 1002, a user interface 1003, a network interface 1004, a memory 1005. Wherein the communication bus 1002 is used to enable connected communication between these components. The user interface 1003 may include a Display, an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may further 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 high-speed random access memory (Random Access Memory, RAM) memory or a stable non-volatile memory (NVM), such as a disk memory. The memory 1005 may also optionally be a storage device separate from the processor 1001 described above.
Those skilled in the art will appreciate that the structure shown in fig. 1 does not constitute a limitation on the data flow control apparatus and may include more or fewer components than shown, or may combine certain components, or may be arranged in a different arrangement of components.
As shown in fig. 1, an operating system, a data storage module, a network communication module, a user interface module, and a data flow control program may be included in the memory 1005 as one type of storage medium.
In the data flow control device shown in fig. 1, the network interface 1004 is mainly used for data communication with other devices; 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 device of the present invention may be disposed in the data flow control device, where the data flow control device invokes a data flow control program stored in the memory 1005 through the processor 1001, and executes the data flow control method provided by the embodiment of the present invention.
An embodiment of the present invention provides a data flow control method, referring to fig. 2, fig. 2 is a schematic flow chart of a first embodiment of the data flow control method of the present invention.
In this embodiment, the data flow control method includes:
Step S10, collecting data backlog values of all data channels;
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 number of threads distributed to the data channels;
And step S30, data transmission is carried out according to the flow control value of each data channel.
The data flow control method of the embodiment can be applied to a data management device, a server or a terminal, and is not limited herein. Firstly, the flow control, namely flow control, is explained, and mainly refers to controlling the concurrency of the threads so as to enable the concurrency of the threads not to exceed a flow control threshold value. Because the data flow of the data flow is unpredictable, when a large amount of data suddenly gushes to the server, the system is crowded and blocked, in order to enable the machine to continue to operate, a part of users can be served as far as possible under the condition of no downtime, the whole flow is ensured to continue to go on, and at the moment, the application must be subjected to flow control.
The scheme data flow control method is mainly used for a specific application scene of multichannel data control, when a data push request is received, data backlog values of all data channels are collected, flow control values are calculated respectively, the flow control values are thread distribution values, node resource redundancy can be judged by monitoring the use condition of a consumer thread pool, and proper resource adjustment is carried out.
The following will explain each step in detail:
Step S10, collecting data backlog values of all data channels;
in one embodiment, data backlog values for each data channel are collected. It will be appreciated that flow control is typically a bi-directional behavior, i.e., production while consuming. Such as message pushing, content is pushed through an asynchronous queue for consumption, which may be needed to affect the speed of the production of the message as the amount of data backlog changes. Therefore, the data backlog value of each data channel is first acquired.
Specifically, data backlog collection is typically implemented using middleware such as Kafka, rabbitMq, which is software that provides general services and functions for applications. And acquiring data backlog values of each channel per second through the shell script, and storing the data backlog values into 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 detected through a command :/data/kafka/bin/kafka-consumer-groups.sh--describe--bootstrap-server 192.128.1.1:9092--group$group--topic$topic, the command is written into a shel l script, the shell script is called at regular time by using a crontab task in linux, and output data is sent to an http interface of an application through a curl command and stored in 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 number of threads distributed to the data channels;
In one embodiment, the flow control value of each data channel is calculated according to the data backlog value and the size of the messaging thread pool. Referring to fig. 3, fig. 3 is a general flow chart of an embodiment of the data flow control method of the present invention, which is explained.
Let the size of the message sending thread pool be k, the real-time data backlog value (corresponding to the collection channel backlog value in fig. 3) be b1, b2, b3 (corresponding to the channels c1, c2, c3 respectively, the same applies) and the data collection time interval be T, and the initialization flow control value of each channel be s, then the latest flow control value s1 of the channel c1 is:
And step S30, data transmission is carried out 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, namely, the speed limitation of sending a thread pool delivery task to a consumer is performed. The issued data is task requests (data) received by all channels in the thread pool, and within the upper limit of the flow control value, the tasks received by all channels are distributed and issued through the thread pool, namely, the thread tasks are executed, for example, information is pushed to consumers. And each node has no mutual interference under the distributed system, and the node resource redundancy can be judged by monitoring the service condition of the consumer thread pool so as to carry out proper resource adjustment.
According to the method, the device and the system, the data backlog value of each channel is collected, 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, and then the resource allocation of each channel is adjusted according to the flow control value of each channel to carry out data issuing, so that reasonable allocation of resources is guaranteed under the condition of multiple channels, and the system efficiency and stability 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 of a refinement step of calculating a flow control value according to a second embodiment of the data flow control method of the present invention, which is different from the first embodiment of the data flow control method in 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, obtaining the target proportion of each data channel; wherein the target ratio comprises: backlog weight ratio and/or abnormal request filtering ratio;
and S22, 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.
In this embodiment, the flow control value may be calculated by a target proportion of each data channel, a data backlog value, and a size of a message sending thread pool, where the target proportion includes: backlog weight proportion and/or exception request filtering 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 messaging 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 the embodiment, the backlog weight proportion of each data channel is obtained, and the backlog weight proportion and the backlog value of each data channel are used together for calculating the flow control value, so that the flow control value can be adjusted according to the service requirement.
The following will explain each step in detail:
Step a, acquiring the backlog weight proportion of each data channel;
In one embodiment, backlog weight ratios for each data channel are obtained. It can be understood that in practical applications, the capacity of each channel is not kept the same, and the flow of each channel can be increased according to the actual requirement, so as to obtain the backlog weight ratio of each channel, that is, increase the number of threads of each channel according to the actual service requirement. Along the example of fig. 3, the backlog weight ratio corresponding to channels c1, c2, c3 is a1: a2: a3. the backlog weight ratio of each channel can 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 the backlog weight proportion of each channel is introduced, that is, the flow control value s is affected by the backlog value duty ratio of the channel and the channel weight, at this time, the calculation formula of the c1 channel flow control value is:
Wherein b1, b2, b3 are data backlog values of each channel; 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 messaging thread pool includes:
Step c, obtaining 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 order to ensure the efficiency of the downstream request, the embodiment performs filtering of the abnormal request, calculates the filtering proportion of the abnormal request of the downstream system by acquiring the flow control trigger times, the data acquisition time interval and the initial flow control value of each data channel of the downstream system, and calculates the flow control value according to the filtering proportion of the downstream abnormal request.
The following will explain each step in detail:
Step c, obtaining an abnormal request filtering proportion;
the method comprises the steps of obtaining an exception request filtering proportion, wherein the exception request filtering proportion is an exception request filtering proportion of a downstream system, and the step of obtaining the exception request filtering proportion comprises the following steps:
Step c1, acquiring the flow control trigger times, the data acquisition time interval and the initialization flow control value of each data channel of a downstream system;
and c2, calculating the abnormal request filtering proportion according to the flow control trigger times, the data acquisition time interval and the initialized flow control value of each data channel.
In an embodiment, the number of flow control triggers of the downstream system is counted, and a data acquisition time interval and an initialization flow control value of each data channel are obtained. Specifically, as 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 of the downstream system is recorded, statistics is carried out 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 per day: 00, 12:00, 14:00, 17:00 is a message pushing peak period, the pushing platform can flow control the whole network, the interface qps of the pushing platform can be lowered from 3000 to 1000, the message sending flow transmitted to the upstream is reflected in that the return state code of the message pushing http interface is 503 (the server is inaccessible), and the number of times of collecting the return code triggering 503 according to time intervals is the number of times of downstream flow control triggering.
The data acquisition time interval refers to the time interval of acquiring data required by calculating the flow control value, the initialization flow control value of each data channel refers to the initial thread value distributed by each channel, and the data acquisition time interval and the initialization flow control value are preset. The downstream abnormal request proportion filtering formula is expressed by e, and the calculated abnormal request filtering ratio is called normal request ratio, and the formula is as follows:
e=1-t1/(s*T)
Wherein the above formula calculates the normal data value during the time period 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 (channel treatable threads) the channel is allowed to trigger, and T1 is the number of flow control triggers. Then the value obtained by subtracting T1/(s×t) from 1 is the ratio at which no flow control is triggered.
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. Taking the example of the c1 channel as an example, the calculation formula of the flow control value s1 is as follows:
Further, in an embodiment, filtering of the abnormal request may be performed on the basis of the backlog weight proportion, while 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 messaging 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.
Along the above example, at this time, the calculation formula is as follows:
Further, in an embodiment, the step of calculating the abnormal request filtering ratio according to the flow control trigger number, the data acquisition time interval and the initialized flow control value of each data channel includes:
Step S23, obtaining a flow control amplification ratio;
And step S24, calculating the filtering proportion of the downstream abnormal request based on the flow control amplification ratio, the flow control trigger times, the data acquisition time interval and the initialized flow control value of each data channel.
According to the embodiment, the abnormal request filtering proportion is calculated by obtaining the flow control amplification ratio, so that amplification optimization of the flow control value can be realized, namely, the downstream flow control is triggered in a certain ratio within the allowable range of the downstream system, and the data is ensured to be issued in a mode of maximum flow.
The respective steps will be described below:
Step S23, obtaining a flow control amplification ratio;
in one embodiment, a flow control amplification ratio is obtained. The flow control amplification ratio is a threshold value, specifically an empirical value obtained by testing. I.e. under the condition of not triggering the flow control, trying to explore upwards, expanding a bit, and if the flow control is triggered after the expansion, then properly adjusting the flow control amplification ratio.
Specifically, the normal range is obtained by 1-T1/(s×t), and the flow control amplification ratio m is added, that is, the expansion is performed without triggering flow control. It should be noted that, the flow control amplification ratio is an empirical value, if the flow control is triggered after the expansion is found, the flow control amplification ratio is reset, and the flow control value is calculated to be reasonable under the amplification ratio by repeated experiments to confirm the flow control amplification ratio.
And step S24, calculating the filtering proportion of the downstream abnormal request based on the flow control amplification ratio, the flow control trigger times, the data acquisition time interval and the initialized flow control value of each data channel.
In an embodiment, the flow control value of each channel is calculated according to a preset flow control amplification ratio, the calculated downstream abnormal request filtering proportion, the collected data backlog value and the size of the message sending thread pool. The flow control upper limit judging mode when a downstream system is requested is optimized, and the resource utilization rate is improved. After the flow control amplification ratio m is obtained, the calculation formula of the abnormal request filtering proportion e is as follows:
Here, examples of actual usage data in the application are:
Assuming that the message pushing channels are divided into an apple c1, a millet c2 and a millet c3, and setting backlog weight proportions of the three channels to be 3 according to the user quantity of each channel system: 1:1, the basic logic is that the ratio is 3 according to the user quantity: 1: 1. The data backlog values of the respective channels are b1=10w, b2=4w, b3=1w, respectively. The downstream flow control data acquisition time interval T is 5s, the current flow control triggering times c1 is 20, c2 is 1000, c3 is 200, the initial flow control value of each data channel is 300, the size of a message sending thread pool is 1000, the flow control amplification ratio of the c1 channel is 1%, and the other flow control amplification ratios are 0. The latest flow control values of the data channels are respectively:
the flow control value is a thread allocation value, and it can be seen that most threads push c1, i.e. apple messages (rising from 300 to 847) to users with the influence of flow control trigger times and backlog data. Dynamic resource translation can be realized through 5s calculation, and the message pushing speed is improved to a more stable and efficient level.
According to the method, the device and the system, the target proportion is set, particularly the backlog weight proportion and/or the abnormal request filtering proportion can be set, so that calculation of the flow control value is influenced by the backlog weight proportion of the data channel and the data backlog value, meanwhile, in order to ensure the downstream request efficiency, abnormal request filtering is further carried out, and the upstream data parameter and the downstream data parameter are reasonably utilized for flow control management through calculation of the downstream abnormal request filtering proportion and setting of the flow control amplification ratio, so that the rationality of resource allocation is ensured.
Further, based on the previous 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 refinement step of acquiring the number of flow control triggers in the third embodiment of the data flow control method according to the present invention, and the difference between the third embodiment of the data flow control method according to the present invention and the previous embodiment of the data flow control method is that the step of acquiring the number of flow control triggers in 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;
step S27, counting the flow control triggering times in the preset time.
In the embodiment, by acquiring the operation index of the downstream system interface and judging whether the flow control triggering condition is met, if the flow control triggering condition is met, triggering the flow control, counting once, and counting the number of times of triggering the flow control in the preset time, the flow control triggering number of times of the downstream system is obtained.
The following will explain each step in detail:
Step S25, judging whether the operation index of the downstream system interface meets the flow control triggering condition;
in an embodiment, when data is sent to a downstream system through an http interface, the triggering and counting of the flow control can be performed by acquiring the operation index of the data and judging whether the operation index meets the flow control triggering condition. The operation 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 running index is RT, the response time of a single request exceeds a threshold value, the flow control is triggered, or the response of the single request exceeds the threshold value in a false way, then the response time of 5 continuous requests in the following 1s is detected, and if the response time exceeds the threshold value, the flow control is triggered.
The flow control trigger can also be obtained by calculating the abnormal proportion: the flow control is triggered by the fact that the number of requests is greater than 5 in one second and the proportion of the abnormal number of requests to the total number of requests is greater than the abnormal proportion.
In addition, the judgment can be performed by the abnormal constant: the abnormal request number in one minute is larger than the set abnormal constant, and the flow control is triggered.
Specifically, the flow control trigger condition can simulate multiple users to perform pressure test on the system by using a pressure measurement tool, and when the average response time of the test exceeds a certain value, the average response time is considered to be unacceptable, and the flow control trigger condition is obtained.
Step S26, if yes, triggering flow control and counting once;
In an embodiment, the flow control is triggered if the operation index of the downstream system satisfies the flow control trigger condition. Specifically, assuming that the operation index is QPS, determining 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, recording as triggering the flow control once.
Step S27, counting the flow control triggering times in the preset time.
In an embodiment, the number of times of triggering the flow control in 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, the flow control value is calculated every 5 seconds, and the corresponding flow control trigger times within 5 seconds are counted.
In the previous embodiment, the flow control trigger times can be obtained by obtaining the error return code, and the present embodiment sets the active trigger condition, and when the running index of the downstream system cannot meet the set normal condition, that is, meet the flow control trigger condition, 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 calculated, it is determined whether the flow control value of each data channel is lower than a preset threshold. It should be noted that, the flow control value of each data channel and the corresponding preset threshold value are compared to obtain the comparison result of the flow control values of all the data channels and the preset threshold value.
In this embodiment, the lowest 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 thread pool size is 1000, 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 preferable scheme to directly perform thread allocation according to the flow control value, the present embodiment further considers the user quantity or actual requirement of each data channel. Assuming that the average flow control value of the channel 3 is 100 and the calculated flow control value of this time interval is 40, the distribution is normally performed directly according to 40, but this may be due to the peak-valley of the data volume or the problem of the temporary data channel receiving thread, and a large amount of data volume may suddenly appear before the flow control value of the next time interval is calculated, so that the problem of untimely adjustment is easy to occur. Therefore, in order to better realize dynamic adjustment of resource allocation, a flow control threshold may be set for each data channel, if the flow control value calculated by one or more channels is lower than the preset threshold, under the condition that normal operation of the data channels with other flow control values not lower than the preset threshold is not affected, the flow control value of the data channels with the flow control value lower than the preset threshold may be set as the preset threshold, and then the flow control values of the other channels are adaptively adjusted. In the above example, the flow control value of the channel 3 may be directly set to 100; as another example, assume that the thread pool size is 1000, and the flow control value of channel 1 is 860, channel 2 is 60, channel 3 is 40, channel 3 is lower than the preset threshold 100, and the flow control value of channel 3 is 80 on the premise that the number of threads is not exceeded and the flow control values of the rest data channels not lower than the preset threshold are not changed, 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, the step of collecting the data backlog value of each data channel is circularly executed according to a preset time interval, the flow control trigger times of a downstream system in a preset time are counted, and the flow control value of each data channel is calculated according to the data backlog value and the flow control trigger times;
And step S32, according to the flow control value obtained by calculation at the preset time interval, adjusting the thread allocation of the message sending thread pool to carry out data issuing.
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 calculated flow control value so as to perform data distribution. Specifically, after calculating the flow control value of each data channel, the flow control values are allocated, and the above examples are used: when the initial flow control values of the three channels c1, c2 and c3 are 300 and the flow control values of the three data channels are calculated (s 1 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 the channel c2 and 24 threads are distributed to the channel c3. The triggering function of collecting statistics according to the preset time interval can be realized by a timer and executed by adopting an independent thread pool. The preset time interval may be set according to actual requirements, such as data acquisition every 10 seconds, every 15 seconds.
According to the embodiment, the operation index of the downstream system interface is obtained, and whether the operation index meets the flow control triggering condition is judged, so that the flow control triggering times are obtained; 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, and if the flow control value is lower than the preset threshold value, adjusting the flow control value of each data channel according to the preset threshold value, so that the lowest available flow of each data channel is ensured. 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 circularly executed, and according to the flow control value obtained by calculation at the preset time interval, the allocation of the message sending thread pool is adjusted to carry out data issuing, so that an elastic 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 schematic diagram of functional modules of an embodiment of the data flow control device of the present invention. The device comprises:
the channel acquisition module 10 is used for acquiring the data backlog value of each data channel;
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 used for issuing data according to the flow control value of each data channel.
Optionally, the flow control calculation module is further configured to:
obtaining the target proportion of each data channel; wherein the target ratio comprises: backlog weight ratio and/or abnormal request filtering ratio;
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 initialization flow control value of each data channel of a 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 or not;
If the flow control triggering condition is met, triggering flow control and counting once;
Counting the flow control triggering times in a preset time.
Optionally, the flow control calculation module is further configured to:
Obtaining a flow control amplification ratio;
And calculating the downstream abnormal request filtering proportion based on the flow control amplification ratio, the flow control trigger 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;
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:
circularly executing the step of collecting the data backlog value of each data channel according to a preset time interval, and calculating the flow control value of each data channel according to the data backlog value and the size of a message sending thread pool;
And adjusting the thread allocation of the message sending thread pool according to the flow control value obtained by calculation at the preset time interval so as to carry out data issuing.
The invention also provides a computer readable storage medium.
The computer readable storage medium of the present invention has stored thereon a data flow control program which, 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 various embodiments of the data flow control method of the present invention, which are not described herein again.
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 one … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The foregoing embodiment numbers of the present invention are merely for the purpose of description, and do not represent the advantages or disadvantages of the embodiments.
From the above description of the embodiments, it will be clear to those skilled in the art that the above-described embodiment method may be implemented by means of software plus a necessary general hardware platform, but of course may also be implemented by means of hardware, but in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a storage medium (e.g. ROM/RAM, magnetic disk, optical disk) as described above, comprising instructions for causing a terminal device (which may be a mobile phone, a computer, a server, or a network device, etc.) to perform the method according to the embodiments of the present invention.
The foregoing description is only of the preferred embodiments of the present invention, and is not intended to limit the scope of the invention, but rather is intended to cover any equivalents of the structures or equivalent processes disclosed herein or in the alternative, which may be employed directly or indirectly in other related arts.

Claims (9)

1. A data flow control method, characterized in that 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, wherein the flow control value is the number of threads distributed to the data channels;
data transmission is carried out according to the flow control values of the data channels;
the step of issuing data according to the flow control value of each data channel comprises the following steps:
the step of circularly executing the data backlog value of each data channel according to the preset time interval 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, wherein the triggering function of collecting statistics according to the preset time interval can be realized by a timer and executed by adopting an independent thread pool;
And adjusting the thread allocation of the message sending thread pool according to the flow control value obtained by calculation at the preset time interval so as to carry out data issuing.
2. The data flow control method of claim 1, wherein the step of calculating the flow control value of each data channel based on the data backlog value and the messaging thread pool size comprises:
obtaining the target proportion of each data channel; wherein the target ratio comprises: backlog weight ratio and/or abnormal request filtering ratio;
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 includes:
acquiring the flow control triggering times, the data acquisition time interval and the initialization flow control value of each data channel 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 initialization 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 number of the downstream system includes:
Judging whether the operation index of the downstream system meets the flow control triggering condition or not;
If the flow control triggering condition is met, triggering flow control and counting once;
Counting the flow control triggering times in a 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 number, the data acquisition time interval and the data channel initialization flow control value comprises:
Obtaining a flow control amplification ratio;
And calculating the downstream abnormal request filtering proportion based on the flow control amplification ratio, the flow control trigger times, the data acquisition time interval and the initialized flow control value of each data channel.
6. The data flow control method according to claim 1, wherein after the step of calculating the flow control value of 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;
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. A data flow control device, the device comprising:
the channel acquisition module is used for acquiring the data backlog value of each data channel;
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;
The data issuing module is used for issuing data according to the flow control value of each data channel;
The flow control calculation module is further configured to circularly execute the step of collecting the data backlog value of each data channel according to a preset time interval, and calculate the flow control value of each data channel according to the data backlog value and the size of the message sending thread pool, where the triggering function of collecting statistics according to the preset time interval can be implemented by a timer and executed by an independent thread pool;
And adjusting the thread allocation of the message sending thread pool according to the flow control value obtained by calculation at the preset time interval so as to carry out data issuing.
8. A data flow control device, the device comprising: a memory, a processor and a data flow control program stored on the memory and executable on the processor, the data flow control program being configured to implement the steps of the data flow control method of any one of claims 1 to 6.
9. A computer readable storage medium, characterized in that the computer readable storage medium has stored thereon a data flow control program, which when executed by a processor, implements the steps of the data flow control method according to any of claims 1 to 6.
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 CN114827033A (en) 2022-07-29
CN114827033B true 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)

Families Citing this family (1)

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

Citations (15)

* 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
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

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9703638B2 (en) * 2013-12-27 2017-07-11 Oracle International Corporation System and method for supporting asynchronous invocation in a distributed data grid

Patent Citations (15)

* 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
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

Also Published As

Publication number Publication date
CN114827033A (en) 2022-07-29

Similar Documents

Publication Publication Date Title
CN109032801B (en) Request scheduling method, system, electronic equipment and storage medium
US8547840B1 (en) Bandwidth allocation of bursty signals
CN111190745B (en) Data processing method, device and computer readable storage medium
CN103699445A (en) Task scheduling method, device and system
CN106936867B (en) Service request response method and device
CN111277640B (en) User request processing method, device, system, computer equipment and storage medium
CN114827033B (en) Data flow control method, device, equipment and computer readable storage medium
CN101984414B (en) Method and device for scheduling central processing unit (CPU) resource
CN109039953B (en) Bandwidth scheduling method and device
CN111045808A (en) Distributed network task scheduling method and device
CN109117280A (en) The method that is communicated between electronic device and its limiting process, storage medium
CN102137091B (en) Overload control method, device and system as well as client-side
CN111813543A (en) Adaptive scheduling method, device and computer readable storage medium
CN115277577A (en) Data processing method, data processing device, computer equipment and computer readable storage medium
CN105740077B (en) Task allocation method suitable for cloud computing
CN111897659B (en) Method, system and device for controlling service processing frequency and electronic equipment
CN114448989A (en) Method, device, electronic equipment, storage medium and product for adjusting message distribution
CN113992586B (en) Flow control method, flow control device, computer equipment and storage medium
CN112463315A (en) Cluster task scheduling method and device and related components
CN113079062B (en) Resource adjusting method and device, computer equipment and storage medium
CN109670932A (en) Credit data calculate method, apparatus, system and computer storage medium
CN115550284A (en) Message processing method, device and equipment
CN109063025A (en) A kind of log processing method and system and a kind of intelligent terminal
CN114979979B (en) Message processing method and message processing system thereof
CN116610266B (en) Method and device for adjusting read-write performance of virtual machine disk and related equipment

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