Method and device for realizing flow control in load balancing system
By using iptables and tc tools in the load balancing system, combined with virtual IP addresses and listener ports, fine-grained control of traffic is achieved, solving the problem of lack of effective traffic control in the load balancing system, improving the system's flexibility and availability, and preventing server overload.
Patent Information
- Application Number
- CN202510992042.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-18
- Publication Date
- 2025-09-16
AI Technical Summary
The existing load balancing system lacks an effective flow control solution, which leads to network overload and server overload problems.
By using iptables and tc tools in the Linux system to limit the maximum number of connections and bandwidth of the load balancing node respectively, and combining the virtual IP address and listener port, fine-grained control of traffic can be achieved.
It effectively prevents server overload and ensures service stability. Users can dynamically adjust traffic control strategies according to business needs, optimize resource allocation, and improve system flexibility and availability.
Smart Images

Figure CN120658747A_ABST
Abstract
Description
Technical Field
[0001] One or more embodiments of the present invention relate to network communication technology, and more particularly, to a method and apparatus for implementing flow control in a load balancing system. Background Art
[0002] Cloud computing has been one of the hottest topics in IT infrastructure in recent years. Its virtualized abstraction of computing, networking, storage, and other resources provides users with extremely convenient resource utilization and flexible resource expansion capabilities. At the same time, the rapid development of computer communication network technologies has made network overload and overload commonplace. To address network overload issues, load balancing technology is needed to provide more flexible, convenient, fast, and efficient cloud computing services. Built on existing network structures, load balancing provides an inexpensive, effective, and transparent method to expand the bandwidth of network devices and servers, increase throughput, enhance network data processing capabilities, and improve network flexibility and availability.
[0003] There are currently many different load balancing technologies to meet different application requirements, such as software / hardware load balancing, local / global load balancing, higher network layer load balancing, and link aggregation technology.
[0004] With the rapid growth of traffic in the network, it is also necessary to implement flow control in the load balancing system. However, there is currently no effective flow control solution for the load balancing system. Summary of the Invention
[0005] One or more embodiments of the present invention describe a method and apparatus for implementing flow control in a load balancing system, which can better implement flow control in the load balancing system.
[0006] According to a first aspect, a method for implementing flow control in a load balancing system is provided, wherein the load balancing system is deployed based on a Linux system; the method further comprises:
[0007] Receive a request from a user to create a flow control;
[0008] Obtaining a flow control policy according to the request to create flow control;
[0009] Sending traffic control policies to load balancing nodes in the load balancing system;
[0010] The load balancing node uses the iptables tool of the Linux system to issue the first rule to limit the maximum number of connections;
[0011] The load balancing node uses the tc tool of the Linux system to issue the second rule, so as to limit the bandwidth through the second rule.
[0012] Limit the maximum number of connections based on the virtual IP address VIP of the load balancing node;
[0013] The load balancing node uses the iptables tool of the Linux system to issue a first rule to limit the maximum number of connections through the first rule, including:
[0014] The first rule is added by directly executing the first iptables command through the command line; wherein, the first iptables command carries the VIP of the load balancing node and the connlimit-above parameter, and the value of the connlimit-above parameter is used to limit the global maximum number of VIP connections, so that the load balancing node rejects any request with a destination address of VIP that exceeds the maximum number of connections.
[0015] Limit bandwidth based on VIP of load balancing nodes;
[0016] The load balancing node uses the tc tool of the Linux system to issue a second rule to limit the bandwidth through the second rule, including:
[0017] Execute the first tc command to configure the root queue discipline, add a main class, add a subclass, and use a filter to direct traffic to the subclass. The first tc command contains the VIP of the load balancing node, the network interface information of the service network to be controlled, the maximum bandwidth to be limited, and the peak bandwidth.
[0018] Write the first tc command into a script and execute it at system startup.
[0019] Implement maximum connection limit based on listener port;
[0020] The load balancing node uses the iptables tool of the Linux system to issue a first rule to limit the maximum number of connections through the first rule, including:
[0021] Directly execute the second iptables command through the command line to add a second rule; wherein the second iptables command carries information about the specified listener port and the connlimit-above parameter, and the maximum number of connections of the listener port is limited by the value of the connlimit-above parameter, so that the load balancing node rejects any request that exceeds the maximum number of connections and whose port number corresponds to the specified listener port.
[0022] Implement maximum bandwidth value limit based on listener port;
[0023] The load balancing node uses the tc tool of the Linux system to issue a second rule to limit the bandwidth through the second rule, including:
[0024] Execute the second tc command to configure the root queue discipline, add a main class, add a subclass, and use a filter to direct traffic to the subclass. The second tc command contains information about the specified listener port, the network interface of the service network to be controlled, and the maximum and peak bandwidth values to be limited.
[0025] Write the second tc command into a script and execute it at system startup.
[0026] Implement maximum connection number and maximum bandwidth value limits based on the listener port.
[0027] The method includes:
[0028] When the current number of TCP connections reaches the preset maximum number of connections, the server will refuse to accept new connection requests to prevent server overload due to too many connections; the server combines the maximum bandwidth value limit to control the bandwidth of established connections.
[0029] When the current number of TCP connections reaches the maximum number of connections, the server does not directly reject new connection requests. Instead, the server marks subsequent new connections and classifies them as non-priority connections. The server implements bandwidth restrictions on non-priority connections. The tc command is used to mark TCP connections that exceed the maximum number of connections. The tc command is used to create queue rules and a class to limit marked traffic. The tc command is used to create filters to match marked traffic.
[0030] According to a second aspect, a device for implementing flow control in a load balancing system is provided, comprising: a control module and a load balancing module; the control module comprises a console and a control backend; wherein,
[0031] The console receives a request for creating flow control initiated by a user in the console according to his / her own needs;
[0032] The control backend is used to obtain a flow control policy according to the request to create flow control; and send the flow control policy to the load balancing module;
[0033] After receiving the instruction, the load balancing module uses the iptables tool of the Linux system to issue a first rule to limit the maximum number of connections through the first rule; and uses the tc tool of the Linux system to issue a second rule to limit the bandwidth through the second rule.
[0034] According to a third aspect, a computing device is provided, comprising a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method described in any embodiment of the present invention is implemented.
[0035] It can be seen that each embodiment of the present invention has at least the following beneficial effects:
[0036] 1. The embodiment of the present invention provides a user-oriented flow control method, allowing users to limit the flow in the load balancing system according to their own needs. For the Linux system, it provides the use of iptables tools and tc tools to issue rules, so that the flow control strategy is reflected through the rules, and the maximum number of connections and maximum bandwidth values are limited, effectively preventing server overload and ensuring service stability. Users can dynamically adjust the flow control strategy according to business needs, optimize resource allocation, and improve the flexibility and availability of the system.
[0037] 2. Allow users to actively control traffic. Users can dynamically adjust traffic control strategies according to business needs, optimize resource allocation, and improve system flexibility and availability.
[0038] 3. This technology is not dependent on a specific load balancer; as long as the entire platform is deployed on a Linux system, it can be easily applied. Its high compatibility and portability ensure flexible deployment and use in different Linux environments.
[0039] 4. Provides flexible traffic management strategies, which can set the maximum number of connections or the maximum bandwidth value separately, or implement both in parallel; users can choose according to their needs. When the number of TCP connections reaches the preset maximum number of connections, the system can take corresponding measures, such as directly rejecting new connections or implementing speed limits on new connections, to optimize network resource allocation, effectively prevent server overload, and ensure service stability. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0041] Figure 1 The present invention is a flowchart of a method for implementing flow control in a load balancing system according to an embodiment of the present invention.
[0042] Figure 2 It is a structural diagram of an apparatus for implementing flow control in a load balancing system in one embodiment of the present invention. DETAILED DESCRIPTION
[0043] The solution provided by the present invention is described below with reference to the accompanying drawings.
[0044] First, it should be noted that the terms used in the embodiments of the present invention are for the purpose of describing specific embodiments only and are not intended to limit the present invention. As used in the embodiments of the present invention and the appended claims, the singular forms "a," "the," and "the" are intended to include the plural forms, unless the context clearly indicates otherwise.
[0045] It should be understood that the term "and / or" as used herein is merely a description of the relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can represent: A exists alone, A and B exist simultaneously, or B exists alone. Furthermore, the character " / " in this document generally indicates that the associated objects are in an "or" relationship.
[0046] Figure 1 This is a flow chart of a method for implementing flow control in a load balancing system in one embodiment of the present invention. The method is based on deploying a load balancing system on a Linux system; see Figure 1 , the method further comprises:
[0047] Step 101: Receive a request from a user to create a flow control function;
[0048] Step 103: Obtain a flow control policy according to the request to create flow control;
[0049] Step 105: Send the traffic control policy to the load balancing node in the load balancing system;
[0050] Step 107: The load balancing node uses the iptables tool of the Linux system to issue a first rule to limit the maximum number of connections;
[0051] Step 109: The load balancing node uses the tc tool of the Linux system to issue a second rule to limit the bandwidth through the second rule.
[0052] according to Figure 1 As can be seen from the illustrated process, the embodiment of the present invention provides a user-oriented flow control method, which allows users to limit the flow in the load balancing system according to their own needs. For the Linux system, it provides the use of iptables tools and tc tools to issue rules, so that the flow control strategy is reflected through the rules, and the maximum number of connections and the maximum bandwidth value are limited, which effectively prevents server overload and ensures service stability. Users can dynamically adjust the flow control strategy according to business needs, optimize resource allocation, and improve the flexibility and availability of the system.
[0053] In an embodiment of the present invention, iptables is a very powerful tool in the Linux operating system that is used to set, maintain, and check packet filtering rules. These rules are integrated into the netfilter framework of the Linux kernel and are used to implement functions such as network address translation (NAT), packet filtering, and port forwarding. Iptables is mainly used to configure the kernel firewall, which can be used to control the data packets flowing into and out of the network interface, thereby providing network security and flow control. tc (Traffic Control) is a flow control tool in the Linux kernel that allows users to manage the transmission of data packets on the network interface through queuing disciplines (qdiscs) and classes. tc is mainly used to implement complex traffic shaping, priority allocation, and bandwidth limitation strategies to optimize the use of network bandwidth and provide quality of service (QoS) guarantees. The maximum number of connections sets the maximum number of concurrent connections, which refers to the maximum number of TCP connections that a load balancing instance can carry when listening at layer 4 or layer 7. When the number of TCP connections on the instance exceeds the maximum number of connections defined in the specification, in order to ensure the performance of existing connection services, new connection requests will be discarded or processed in other ways.
[0054] The embodiments of the present invention improve the flexibility, availability, and service stability of the load balancing system, and can achieve the following goals:
[0055] 1. Allow users to actively control traffic. Users can dynamically adjust traffic control strategies according to business needs, optimize resource allocation, and improve system flexibility and availability.
[0056] 2. This technology is not dependent on a specific load balancer; as long as the entire platform is deployed on a Linux system, it can be easily applied. Its high compatibility and portability ensure flexible deployment and use in different Linux environments.
[0057] 3. Provide flexible traffic management strategies, which can set the maximum number of connections or the maximum bandwidth value separately, or implement both in parallel; users can choose according to their needs. When the number of TCP connections reaches the preset maximum number of connections, the system can take corresponding measures, such as directly rejecting new connections or implementing speed limits on new connections, to optimize network resource allocation, effectively prevent server overload, and ensure service stability.
[0058] In one embodiment of the present invention, flow control can be achieved by:
[0059] 1. Limit the maximum number of connections based on the virtual IP address (VIP) of the load balancing node;
[0060] At this time, in step 107, the load balancing node uses the iptables tool of the Linux system to issue a first rule to limit the maximum number of connections through the first rule, including:
[0061] Step 1071: Directly execute the first iptables command through the command line to add the first rule; wherein, the first iptables command carries the VIP of the load balancing node and the connlimit-above parameter, and the value of the connlimit-above parameter is used to limit the global maximum number of VIP connections, so that the load balancing node rejects any request with a destination address of VIP that exceeds the maximum number of connections.
[0062] 2. Limit bandwidth based on VIP of load balancing node;
[0063] At this time, in step 109, the load balancing node uses the tc tool of the Linux system to issue a second rule to limit the bandwidth through the second rule, including:
[0064] Step 1091: Execute the first tc command to configure the root queue discipline, add a main class, add a subclass, and use a filter to direct traffic to the subclass. The first tc command carries the VIP of the load balancing node, the network interface information of the service network to be controlled, the maximum bandwidth to be limited, and the peak bandwidth.
[0065] Write the first tc command into a script and execute it at system startup.
[0066] 3. Based on the virtual IP address VIP of the load balancing node, the maximum number of connections and the bandwidth can be limited at the same time. This process can be achieved by combining the above step 1071 with the above step 1091.
[0067] 4. Implement maximum connection limit based on listener port;
[0068] At this time, in step 107, the load balancing node uses the iptables tool of the Linux system to issue a first rule to limit the maximum number of connections through the first rule, including:
[0069] Step 1073: Directly execute the second iptables command through the command line to add a second rule; wherein the second iptables command carries the information of the specified listener port and the connlimit-above parameter, and the maximum number of connections of the listener port is limited by the value of the connlimit-above parameter, so that the load balancing node rejects any request that exceeds the maximum number of connections and the port number corresponds to the specified listener port.
[0070] 5. Implement maximum bandwidth limit based on listener port;
[0071] At this time, in step 109, the load balancing node uses the tc tool of the Linux system to issue a second rule to limit the bandwidth through the second rule, including:
[0072] Step 1093: Execute the second tc command to configure the root queue discipline, add a main class, add a subclass, and use a filter to direct traffic to the subclass. The second tc command carries information about the specified listener port, the network interface of the service network to be controlled, and the maximum and peak bandwidth values to be limited.
[0073] Write the second tc command into a script and execute it at system startup.
[0074] 6. Implement maximum connection number and maximum bandwidth value limits based on the listener port.
[0075] In this case, the method includes:
[0076] When the current number of TCP connections reaches the preset maximum number of connections, the server will refuse to accept new connection requests to prevent server overload due to excessive number of connections; the server will control the bandwidth of established connections in combination with the maximum bandwidth value limit;
[0077] or,
[0078] When the current number of TCP connections reaches the maximum number of connections, the server does not directly reject new connection requests. Instead, the server marks subsequent new connections and classifies them as non-priority connections. The server implements bandwidth restrictions on non-priority connections. The tc command is used to mark TCP connections that exceed the maximum number of connections. The tc command is used to create queue rules and a class to limit marked traffic. The tc command is used to create filters to match marked traffic.
[0079] In one embodiment of the present invention, a device for implementing flow control in a load balancing system is proposed. Figure 2 The device includes: a control module 201 and a load balancing module 202; the control module includes a console 2011 and a control backend 2012; wherein,
[0080] The console 2011 receives a request from a user to create a flow control function according to his / her needs.
[0081] The control backend 2012 is used to obtain a flow control policy according to the request to create flow control; and send the flow control policy to the load balancing module 202;
[0082] After receiving the instruction, the load balancing module 202 uses the iptables tool of the Linux system to issue a first rule to limit the maximum number of connections through the first rule; and uses the tc tool of the Linux system to issue a second rule to limit the bandwidth through the second rule.
[0083] In the embodiment of the present invention, the load balancing module can be a single node or multiple nodes, and can be an active-standby mode or an active-active mode. After receiving the instruction, the load balancing module uses iptables and tc (Traffic Control) to issue rules and create or delete flow control policies.
[0084] Figure 2 The modular design shown makes the system flexible and scalable, and can be adjusted and optimized according to actual needs.
[0085] It can be seen that in the embodiment of the present invention, flow control mainly has two aspects, the maximum number of connections and the maximum bandwidth value. The user can set the maximum number of connections or the maximum bandwidth value separately, or implement both in parallel; the user can choose according to needs. When the number of TCP connections reaches the preset maximum number of connections, the system can take corresponding measures, such as directly rejecting new connections or implementing speed limits on new connections, so as to optimize network resource allocation, effectively prevent server overload, and ensure service stability.
[0086] Traffic control policies play a crucial role in load balancing, ensuring the proper allocation of network resources and high service availability. Depending on the application scenario and requirements, traffic control policies can be broadly categorized into two main types: one that sets traffic limits based on the VIP (Virtual IP) as a whole, and the other that sets traffic limits based on individual listeners (ports). These two types of traffic control methods are tailored to different service scenarios.
[0087] First, setting traffic limits based on the VIP as a whole primarily manages outbound bandwidth between multiple load balancing instances. In practice, to prevent network congestion caused by competition for limited outbound bandwidth between different load balancing instances, it's necessary to set overall traffic limits on load balancing instances serving non-critical services. This policy can be adjusted based on actual conditions to ensure that critical services remain operational during peak network times. By setting traffic limits for VIPs, we can effectively ensure the proper allocation of network resources across multiple load balancing instances, improving overall service stability.
[0088] Secondly, setting traffic limits based on individual listeners (ports) allows for refined management within the same load balancing instance. In a load balancing instance, listeners with multiple ports are often configured to handle different business needs. During operation, these listeners may compete with each other for connection numbers and bandwidth resources, thus affecting business stability. To ensure the priority of important businesses, we need to implement traffic control policies on other non-important listeners. This port-based traffic control can be personalized for the actual business scenario of each listener, thereby maximizing the utilization of network resources while ensuring the stability of important businesses.
[0089] The following example illustrates this.
[0090] In an embodiment of the present invention, the specific steps of implementing flow control may include:
[0091] 1) Implementing maximum connection limit based on VIP
[0092] Use iptables to issue rules on the load balancing node to limit the maximum number of connections. For example, the iptables command is:
[0093] iptables-A INPUT-d 192.168.1.100-p tcp-m connlimit--connlimit-above100-j REJECT
[0094] This rule will deny any more than 100 requests destined for 192.168.1.100.
[0095] 2) Implementing maximum bandwidth limit based on VIP
[0096] Use tc to issue rules to limit bandwidth on the load balancing node. For example, the tc command is:
[0097] tcqdisc add dev eth0 root handle 1:htb default 12
[0098] Create a root queue discipline, where eth0 is the network interface of the service network to be controlled and 1: is the handle of the queue discipline.
[0099] tc class add dev eth0 parent 1:classid 1:1htb rate 1mbps ceil 1mbps
[0100] rate is the maximum bandwidth value to be limited, and ceil is the peak bandwidth value, which is set to 1Mbps here.
[0101] sudotc filter add dev eth0 protocol ip parent 1:0prio 1u32 matchipdst192.168.1.100flowid 1:1
[0102] Here, we match traffic with a destination IP address of 192.168.1.100 and direct it to the 1:1 class. 192.168.1.100 is the VIP of the load balancing instance.
[0103] 3) Implementing maximum connection number and maximum bandwidth limit based on VIP
[0104] Use iptables and tc to issue specifications on the load balancing node to limit the maximum number of connections and bandwidth. The commands include:
[0105] iptables-A INPUT-d 192.168.1.100-p tcp-m connlimit--connlimit-above100-j REJECT
[0106] This rule will deny any more than 100 requests destined for 192.168.1.100.
[0107] tcqdisc add dev eth0 root handle 1:htb default 12
[0108] Create a root queue discipline, where eth0 is the network interface of the service network to be controlled and 1: is the handle of the queue discipline.
[0109] tc class add dev eth0 parent 1:classid 1:1htb rate 1mbps ceil 1mbps
[0110] rate is the maximum bandwidth value to be limited, and ceil is the peak bandwidth value, which is set to 1Mbps here.
[0111] sudotc filter add dev eth0 protocol ip parent 1:0prio 1u32 matchipdst192.168.1.100flowid 1:1
[0112] Here, we match traffic with a destination IP address of 192.168.1.100 and direct it to the 1:1 class. 192.168.1.100 is the VIP of the load balancing instance.
[0113] 4) Implementing maximum connection limit based on listener (port)
[0114] Use iptables to issue rules on the load balancing node to limit the maximum number of connections. The tc command includes:
[0115] iptables -A INPUT -p tcp --dport 8080 -m connlimit --connlimit-above 100-jREJECT
[0116] This rule will deny any more than 100 connections to port 8080.
[0117] 5) Based on the listener (port), the maximum bandwidth value limit is implemented. The tc command includes
[0118] Use tc to limit bandwidth:
[0119] tcqdisc add dev eth0 root handle 1:htb default 12
[0120] Create a root queue discipline, where eth0 is the network interface of the service network to be controlled and 1: is the handle of the queue discipline.
[0121] tc class add dev eth0 parent 1:classid 1:1htb rate 1mbps ceil 1mbps
[0122] rate is the maximum bandwidth value to be limited, and ceil is the peak bandwidth value, which is set to 1Mbps here.
[0123] tc filter add dev eth0 protocol ip parent 1:0prio 1u32 match ipdport8080 0xffff flowid 1:1
[0124] Here, we match traffic with a destination port of 8080 and direct it to the 1:1 class.
[0125] 6) Implement maximum connection number and maximum bandwidth value limits based on listener (port)
[0126] There are two specific implementations for implementing maximum connection and bandwidth limits based on listeners (ports):
[0127] a) Option 1: When the current number of TCP connections reaches the preset maximum number of connections, the server will take the following measures to limit it. First, the server will refuse to accept new connection requests to prevent server overload due to excessive connections. At the same time, the server will also combine the maximum bandwidth limit to control the bandwidth of established connections. Specifically, when it detects that the total bandwidth usage reaches or exceeds the preset maximum bandwidth value, the server will implement corresponding policies, such as limiting the bandwidth of a single connection and reducing the data transmission rate, to ensure that overall bandwidth usage remains within a controllable range. This solution can effectively prevent system performance degradation caused by excessive connections or excessive bandwidth usage.
[0128] Use iptables and tc to issue rules:
[0129] iptables -A INPUT -p tcp --dport 8080 -m connlimit --connlimit-above 100-jREJECT
[0130] This rule will deny any more than 100 connections to port 8080.
[0131] tcqdisc add dev eth0 root handle 1:htb default 12
[0132] tc class add dev eth0 parent 1:classid 1:1htb rate 1mbps ceil 1mbps
[0133] tc filter add dev eth0 protocol ip parent 1:0prio 1u32 match ipdport8080 0xffff flowid 1:1
[0134] b) Solution 2: When the current number of TCP connections reaches the maximum, the server no longer directly rejects new connection requests. Instead, it adopts a marking and limiting strategy. Specifically, the server marks subsequent new connections as "non-priority connections." The server then applies bandwidth limits to these non-priority connections, minimizing their bandwidth usage. This ensures that even when the connection limit is reached, the server can maintain a certain level of processing power, providing relatively stable service for higher-priority connections. This solution also helps prevent malicious users from overwhelming server resources with a large number of new connections, thereby improving server security.
[0135] iptables-t mangle-A OUTPUT-p tcp--dport 8080-m connlimit--connlimit-above 100-j MARK--set-mark 1
[0136] This rule will mark TCP connections that exceed the connection limit.
[0137] tcqdisc add dev eth0 root handle 1:htb
[0138] Creating a Queue Discipline
[0139] sudotc class add dev eth0 parent 1:classid 1:10htb rate 10kbps ceil10kbps
[0140] Create a class to restrict tagged traffic
[0141] sudotc filter add dev eth0 protocol ip parent 1:0prio 1handle1fwflowid 1:10
[0142] Create a filter to match the marked traffic
[0143] In the above example, any traffic with more than 100 connections to port 8080 will be marked and its bandwidth will be limited to 10kbps.
[0144] In short, implementing traffic control strategies helps optimize network resource allocation and improve business operational efficiency. By properly utilizing both VIP-based overall traffic limits and listener (port)-based individual traffic limits, we can ensure that all types of services are effectively protected in complex and changing network environments, thereby creating greater value for the enterprise.
[0145] An embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed in a computer, the computer is caused to execute the method in any one of the embodiments in the specification.
[0146] An embodiment of the present invention provides a computing device, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method in any embodiment of the specification is implemented.
[0147] It should be understood that the structures illustrated in the embodiments of the present invention do not constitute specific limitations on the apparatus of the embodiments of the present invention. In other embodiments of the present invention, the apparatus may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0148] The various embodiments of the present invention are described in a progressive manner. Similar portions between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences between the other embodiments. In particular, the device embodiments are generally similar to the method embodiments, so their description is relatively simple. For relevant portions, refer to the description of the method embodiments.
[0149] Those skilled in the art will appreciate that in one or more of the above examples, the functions described in the present invention may be implemented using hardware, software, widgets, or any combination thereof. When implemented using software, these functions may be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium.
[0150] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent replacements, improvements, etc. made on the basis of the technical solution of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for implementing flow control in a load balancing system, characterized in that: Deploy a load balancing system based on a Linux system; the method further includes: Receive a request from a user to create a flow control; Obtaining a flow control policy according to the request to create flow control; Sending traffic control policies to load balancing nodes in the load balancing system; The load balancing node uses the iptables tool of the Linux system to issue the first rule to limit the maximum number of connections; The load balancing node uses the tc tool of the Linux system to issue the second rule, so as to limit the bandwidth through the second rule.
2. The method according to claim 1, characterized in that Limit the maximum number of connections based on the virtual IP address VIP of the load balancing node; The load balancing node uses the iptables tool of the Linux system to issue a first rule to limit the maximum number of connections through the first rule, including: The first rule is added by directly executing the first iptables command through the command line; wherein the first iptables command carries the VIP of the load balancing node and the connlimit-above parameter, and the global maximum number of VIP connections is limited by the value of the connlimit-above parameter.
3. The method according to claim 1 or 2, characterized in that Limit bandwidth based on VIP of load balancing nodes; The load balancing node uses the tc tool of the Linux system to issue a second rule to limit the bandwidth through the second rule, including: Execute the first tc command to configure the root queue discipline, add a main class, add a subclass, and use a filter to direct traffic to the subclass. The first tc command contains the VIP of the load balancing node, the network interface information of the service network to be controlled, the maximum bandwidth to be limited, and the peak bandwidth. Write the first tc command into a script and execute it at system startup.
4. The method according to claim 1, wherein Implement maximum connection limit based on listener port; The load balancing node uses the iptables tool of the Linux system to issue a first rule to limit the maximum number of connections through the first rule, including: The second rule is added by directly executing the second iptables command through the command line; wherein the second iptables command carries information of the specified listener port and the connlimit-above parameter, and the maximum number of connections of the listener port is limited by the value of the connlimit-above parameter.
5. The method according to claim 1 or 4, characterized in that Implement maximum bandwidth value limit based on listener port; The load balancing node uses the tc tool of the Linux system to issue a second rule to limit the bandwidth through the second rule, including: Execute the second tc command to configure the root queue discipline, add a main class, add a subclass, and use a filter to direct traffic to the subclass. The second tc command contains information about the specified listener port, the network interface of the service network to be controlled, and the maximum and peak bandwidth values to be limited. Write the second tc command into a script and execute it at system startup.
6. The method according to claim 1, characterized in that Implement maximum connection number and maximum bandwidth value limits based on the listener port.
7. The method according to claim 6, characterized in that The method includes: When the current number of TCP connections reaches the preset maximum number of connections, the server will refuse to accept new connection requests to prevent server overload due to too many connections; the server combines the maximum bandwidth value limit to control the bandwidth of established connections.
8. The method according to claim 6, characterized in that When the current number of TCP connections reaches the maximum number of connections, the server does not directly reject new connection requests. Instead, the server marks subsequent new connections and classifies them as non-priority connections. The server implements bandwidth restrictions on non-priority connections. The tc command is used to mark TCP connections that exceed the maximum number of connections. The tc command is used to create queue rules and a class to limit marked traffic. The tc command is used to create filters to match marked traffic.
9. A device for implementing flow control in a load balancing system, characterized in that: include: Control module and load balancing module; the control module includes a console and a control backend; wherein, The console receives a request for creating flow control initiated by a user in the console according to his / her own needs; The control backend is used to obtain a flow control policy according to the request to create flow control; and send the flow control policy to the load balancing module; After receiving the instruction, the load balancing module uses the iptables tool of the Linux system to issue a first rule to limit the maximum number of connections through the first rule; and uses the tc tool of the Linux system to issue a second rule to limit the bandwidth through the second rule.
10. A computing device comprising a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method according to any one of claims 1 to 8 is implemented.