CN101610283B - Method for balancing dynamic receiving load under network card binding state - Google Patents
Method for balancing dynamic receiving load under network card binding state Download PDFInfo
- Publication number
- CN101610283B CN101610283B CN2009100172327A CN200910017232A CN101610283B CN 101610283 B CN101610283 B CN 101610283B CN 2009100172327 A CN2009100172327 A CN 2009100172327A CN 200910017232 A CN200910017232 A CN 200910017232A CN 101610283 B CN101610283 B CN 101610283B
- Authority
- CN
- China
- Prior art keywords
- slave
- traffic
- client
- recv
- rlb
- 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
Links
Images
Landscapes
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
本发明提供一种网卡绑定状态下动态接收负载均衡的方法,该方法是为了解决网卡绑定状态下,接收负载均衡的问题,需要对每个slave收到数据流量做统计,并对流量进行定时检测,在检测到网卡的接收流量不均衡时,通过向客户端发送arp reply包的方式令某些客户端更改其arp缓存中服务器ip对应的mac地址,改变客户端到服务器每个网卡的流量分布,以实现动态接收负载均衡。通过对bonding中每个slave接收到的ip包流量定时做统计分析,在slave流量不均衡的情况下向某些客户端发送arp reply包,令其改变arp缓存中服务器ip对应的mac地址,从而实现服务器上绑定的网卡接收流量的动态均衡。
The present invention provides a method for dynamic receiving load balancing in a network card binding state. The method is to solve the problem of receiving load balancing in the network card binding state. It is necessary to make statistics on the data flow received by each slave, and perform regular detection on the flow. When it is detected that the receiving flow of the network card is unbalanced, some clients are required to change the MAC address corresponding to the server IP in their ARP cache by sending an ARP reply packet to the client, and the flow distribution from the client to each network card of the server is changed to achieve dynamic receiving load balancing. By regularly performing statistical analysis on the IP packet flow received by each slave in bonding, an ARP reply packet is sent to some clients in the case of unbalanced slave flow, so that they are required to change the MAC address corresponding to the server IP in the ARP cache, thereby achieving dynamic balancing of the receiving flow of the network card bound to the server.
Description
技术领域 technical field
本发明涉及计算机系统及通信技术领域,具体涉及一种网卡绑定状态下动态负载均衡的方法。 The invention relates to the field of computer systems and communication technologies, in particular to a method for dynamic load balancing in a network card binding state. the
技术背景 technical background
在服务器上通常装有多个网卡,为了提高传输的带宽和链路的冗余性,通常采用网卡绑定技术,将多个网卡绑定成一个虚拟设备,设置统一的ip来对外提供服务。在linux系统中内核本身已自带了网卡绑定功能,具有6种绑定模式,且以Adaptive load balancing(alb)模式因为对交换机没有特殊要求、可以实现发送和接收的均衡,应用比较普遍。 There are usually multiple network cards installed on the server. In order to improve the transmission bandwidth and link redundancy, the network card binding technology is usually used to bind multiple network cards into a virtual device and set a unified IP to provide external services. In the Linux system, the kernel itself has its own network card binding function, with 6 binding modes, and the Adaptive load balancing (alb) mode is widely used because it has no special requirements for the switch and can achieve the balance of sending and receiving. the
在linux内核的bonding模块中,Adaptive load balancing(alb)模式下,通过对发送的数据量做统计来选择发送设备,因此发送均衡的效果比较理想。根据其说明文档对接收流量也有均衡能力,但是在实际使用中,如两个网卡绑定的情况下,会出现只有一个网卡接收数据的情况。分析其代码,可以发现bonding模块通过为每个客户端分配不同的网卡接收数据,但是未对接收到的流量做统计,在客户端流量差别比较大的情况下,难以做到真正的接收负载均衡。 In the bonding module of the linux kernel, in Adaptive load balancing (alb) mode, the sending device is selected by making statistics on the amount of data sent, so the effect of sending balancing is ideal. According to its documentation, it also has the ability to balance the receiving traffic, but in actual use, for example, when two network cards are bound, only one network card will receive data. Analyzing its code, it can be found that the bonding module receives data by assigning different network cards to each client, but does not make statistics on the received traffic. It is difficult to achieve real receiving load balancing when the client traffic varies greatly. . the
发明内容 Contents of the invention
本发明的目的是提供一种网卡绑定状态下动态接收负载均衡的方法。 The purpose of the present invention is to provide a method for dynamically receiving load balancing in the network card binding state. the
本发明的目的是按以下方式实现的,为了解决网卡绑定状态下,接收负载均衡的问题,需要对每个slave收到数据流量做统计,并对流量进行定时检测,在检测到网卡的接收流量不均衡时,通过向客户端发送arp reply包的方式令某些客户端更改其arp缓存中服务器ip对应的mac地址,改变客户端到服务器每个网卡的流量分布,以实现动态接收负载均衡。 The purpose of the present invention is achieved in the following manner. In order to solve the problem of receiving load balance under the network card binding state, it is necessary to make statistics on the data traffic received by each slave, and perform regular detection of the traffic. When the traffic is unbalanced, send arp reply packets to the client to make some clients change the mac address corresponding to the server ip in their arp cache, and change the traffic distribution from the client to each network card of the server to achieve dynamic receiving load balancing . the
通过对bonding中每个slave接收到的ip包流量定时做统计分析,在slave流量不均衡的情况下向某些客户端发送arp reply包,令其改变arp缓存中服务器ip对应的mac地址,从而实现服务器上绑定的网卡接收流量的动态均衡,具体步骤如下: By statistically analyzing the flow of IP packets received by each slave in bonding, and sending arp reply packets to some clients when the flow of the slave is unbalanced, it will change the mac address corresponding to the server IP in the arp cache, thereby Realize the dynamic balance of the received traffic of the network card bound on the server, the specific steps are as follows:
1)在ip层的接收函数ip_rcv中加入流量分析过程,对ip_src,ip_dst,slave三元组的流量进行统计,从skb中对包的源ip、目的ip及接收此包的slave进行提取,将ip_src,ip_dst,slave中的流量进行累加; 1) Add a traffic analysis process in the receiving function ip_rcv of the ip layer, count the traffic of ip_src, ip_dst, and slave triplets, and extract the source ip, destination ip, and slave receiving the packet from skb. The traffic in ip_src, ip_dst, and slave is accumulated;
2)在bonding模块中,alb方式下的定时器处理函数bond_alb_monitor中根据ip_src,ip_dst,slave的流量统计,判断每个slave的接收流量是否均衡,不均衡向某些客户端发送arp reply包,令客户端改变其arp缓存中服务器ip对应的mac,实现客户端流量在每个slave上的重新分配。 2) In the bonding module, the timer processing function bond_alb_monitor in the alb mode judges whether the receiving traffic of each slave is balanced according to the traffic statistics of ip_src, ip_dst and slave, and sends arp reply packets to some clients unbalanced, so that The client changes the mac corresponding to the server ip in its arp cache to realize the redistribution of client traffic on each slave. the
本发明的有益效果是:在客户端流量差别比较大的情况下,做到真正的接收负载均衡。 The beneficial effect of the invention is: in the case of relatively large differences in client flow, real receiving load balancing can be achieved. the
附图说明 Description of drawings
附图1是rlb_client_recv_info的存储结构图; Attached Figure 1 is a storage structure diagram of rlb_client_recv_info;
附图2是alb的定时器处理函数中进行不均衡度计算和调整的流程图。 Accompanying drawing 2 is the flow chart of calculating and adjusting the unbalance degree in the timer processing function of alb. the
具体实施方式 Detailed ways
参照附图对本发明的方法作以下详细的说明。 The method of the present invention is described in detail below with reference to the accompanying drawings. the
为便于对流量进行统计,需要定义以下数据结构: In order to facilitate statistics on traffic, the following data structures need to be defined:
c)记录从每个客户端接收到流量的数据结构rlb_client_recv_info,包括以下成员: c) The data structure rlb_client_recv_info that records traffic received from each client includes the following members:
ip_src /*客户端ip地址*/ ip_src /*client ip address*/
ip_dst /*服务器ip地址*/ ip_dst /*server ip address*/
mac_src /*客户端的mac地址*/ mac_src /* client mac address */
load /*一个检测周期内接收的数据流量*/ load /*Data traffic received in a detection cycle*/
slave /*分配给此客户端的用于接收数据的网卡*/ slave /*The network card assigned to this client to receive data*/
将相同slave客户端流量信息以双向链表的形式进行组织,因此每个bond会有同其slave相同个数的链表用于记录从所有客户端接收的流量信息。 The traffic information of the same slave client is organized in the form of a two-way linked list, so each bond has the same number of linked lists as its slaves to record the traffic information received from all clients. the
d)记录一个周期内每个slave流量的数组rlb_slave_recv_info,每个slave的流量通过将rlb_client_recv_info结构中相同slave的流量累加获取。 d) Record the array rlb_slave_recv_info of each slave traffic in a period, and the traffic of each slave is obtained by accumulating the traffic of the same slave in the rlb_client_recv_info structure. the
为了对流量进行统计和动态均衡,需要以下处理过程: In order to perform statistics and dynamic balance on traffic, the following processes are required:
(3)在ip层的接收函数ip_rcv中加入流量统计过程,对收到的ip包长度进行累加。 (3) Add the traffic statistics process in the receiving function ip_rcv of the ip layer, and accumulate the lengths of the received ip packets. the
可以从ip_rcv的参数skb中获取ip包的源ip、目的ip、ip包长度,以及接收此包的网卡,然后将对应rlb_client_recv_info中的接收流量load累加。 You can get the source ip, destination ip, ip packet length of the ip packet from the parameter skb of ip_rcv, and the network card that receives this packet, and then accumulate the received traffic load in the corresponding rlb_client_recv_info. the
(4)在alb均衡方式的定时器处理函数bond_alb_monitor中,每隔10秒(可由用户在加载模块时指定)将每个slave的流量进行统计,并检测流量是否均衡,在不均衡的情况下对每个客户端分配的slave进行调整,并向此客户端发送arpreply包。 (4) In the timer processing function bond_alb_monitor of the alb balance method, the traffic of each slave is counted every 10 seconds (can be specified by the user when loading the module), and the traffic is checked to see if the traffic is balanced. The slave allocated by each client adjusts and sends an arpreply packet to this client. the
●将相同slave的rlb_client_recv_info的接收流量累加,以计算出每个 slave的接收流量rlb_slave_recv_info,并按照如下方式计算其不均衡度: ●Accumulate the received traffic of rlb_client_recv_info of the same slave to calculate the received traffic rlb_slave_recv_info of each slave, and calculate its imbalance as follows:
i求所有slave接收流量累加和的平均值rlb_slave_recv_average_load i Find the average value of the cumulative sum of all slave received traffic rlb_slave_recv_average_load
ii求每个slave与上述平均值差值的绝对值,并将每个slave的绝对差值累加求和,然后将和值求平均 ii Find the absolute value of the difference between each slave and the above average value, and sum the absolute difference of each slave, and then average the sum
iii将ii中的平均差值除以i中的平均值,计算其百分比,若超过阈值20%则需要调整。此阈值可通过测试调整。 iii Divide the average difference in ii by the average in i to calculate its percentage, if it exceeds the threshold of 20%, it needs to be adjusted. This threshold can be adjusted through testing. the
若不需要对流量进行调整,则将每个rlb_client_recv_info中的接收流量清零,以便下次进行统计计算。 If there is no need to adjust the traffic, clear the received traffic in each rlb_client_recv_info for the next statistical calculation. the
若需要进行调整,则按下述方式对每个client所分配的用于接收的slave进行调整: If adjustment is required, adjust the receiving slave assigned by each client as follows:
(i)将相同slave的双向链表中的rlb_client_recv_info元素按接收流量从大到小进行排序,并删除流量为零的元素。 (i) Sort the rlb_client_recv_info elements in the doubly linked list of the same slave according to the received traffic from large to small, and delete the elements with zero traffic. the
(ii)将接收流量超过rlb_slave_recv_average_load的slave的双向链表中的rlb_client_recv_info元素从最小流量开始删除,将其添加到一个临时的链表temp_client_list中,直到此slave的剩余rlb_client_recv_info元素的load累加值刚刚超过rlb_slave_recv_average_load,若再删除一个元素则低于此值。 (ii) Delete the rlb_client_recv_info element in the doubly-linked list of the slave that receives traffic exceeding rlb_slave_recv_average_load from the minimum traffic, and add it to a temporary linked list temp_client_list until the cumulative load value of the remaining rlb_client_recv_info elements of the slave just exceeds rlb_slave_recv_average_load, if Remove one more element below this value. the
(iii)将tmp_client_list中的元素按load值从大到小进行排序,然后将其元素轮询加入到接收流量低于rlb_slave_recv_average_load的slave的链表中(从接收流量最小的slave开始) (iii) Sort the elements in the tmp_client_list from large to small according to the load value, and then add its elements to the linked list of slaves whose received traffic is lower than rlb_slave_recv_average_load (starting from the slave with the smallest received traffic)
(iv)按照调整后的每个slave的rlb_client_recv_info链表,使用步骤一的方式计算其不均衡度,若不均衡度已符合要求,则进行下一步,否则在此调整结果的基础上继续调整最多迭代3次,若仍不符合均衡度要求,则放弃调整直接进行下一步 (iv) According to the adjusted rlb_client_recv_info linked list of each slave, use the method of step 1 to calculate its unbalanced degree. If the unbalanced degree meets the requirements, proceed to the next step. Otherwise, continue to adjust the maximum iterations based on the adjusted result 3 times, if it still does not meet the balance requirements, then give up the adjustment and go directly to the next step
(v)向每个所分配slave发生改变的client发送arp reply包,令客户端arp缓存中服务器ip对应的Mac指向新分配的slave。每个客户端的mac地址在原有的alb实现中已作记录,可以直接利用,不需要外加获取。最后将每个rlb_client_recv_info中的接收流量清零。 (v) Send an arp reply packet to each client whose assigned slave changes, so that the Mac corresponding to the server ip in the client's arp cache points to the newly assigned slave. The mac address of each client has been recorded in the original alb implementation and can be used directly without additional acquisition. Finally, clear the received traffic in each rlb_client_recv_info. the
Claims (1)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN2009100172327A CN101610283B (en) | 2009-07-17 | 2009-07-17 | Method for balancing dynamic receiving load under network card binding state |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN2009100172327A CN101610283B (en) | 2009-07-17 | 2009-07-17 | Method for balancing dynamic receiving load under network card binding state |
Publications (2)
Publication Number | Publication Date |
---|---|
CN101610283A CN101610283A (en) | 2009-12-23 |
CN101610283B true CN101610283B (en) | 2012-04-25 |
Family
ID=41483861
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN2009100172327A Active CN101610283B (en) | 2009-07-17 | 2009-07-17 | Method for balancing dynamic receiving load under network card binding state |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN101610283B (en) |
Families Citing this family (16)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101778050A (en) * | 2010-03-11 | 2010-07-14 | 浪潮(北京)电子信息产业有限公司 | Load balancing method, device and system |
CN101815033B (en) * | 2010-03-12 | 2013-04-24 | 成都市华为赛门铁克科技有限公司 | Method, device and system for load balancing |
CN102118319B (en) | 2011-04-06 | 2013-09-18 | 杭州华三通信技术有限公司 | Traffic load balancing method and device |
CN103067976B (en) * | 2013-02-07 | 2015-08-05 | 深圳市磊科实业有限公司 | A kind of load-balancing method and implement device with the WAP (wireless access point) of multiplex roles |
CN104079486A (en) | 2013-03-28 | 2014-10-01 | 国际商业机器公司 | Gateway and method of transmitting data through gateway |
CN103873338A (en) * | 2014-03-11 | 2014-06-18 | 上海爱数软件有限公司 | Method for realizing network virtualization by utilizing binding and VLANs (Virtual Local Area Networks) |
CN104468388A (en) * | 2014-11-04 | 2015-03-25 | 浪潮电子信息产业股份有限公司 | Linux system based test method for network card load balancing |
CN105049284A (en) * | 2015-07-09 | 2015-11-11 | 浪潮电子信息产业股份有限公司 | Linux system-based network redundancy testing method and device |
CN105049368A (en) * | 2015-08-25 | 2015-11-11 | 湖南餐智科技有限公司 | Priority-based load balancing algorithm in hybrid network |
CN105450538A (en) * | 2015-10-15 | 2016-03-30 | 北京锐安科技有限公司 | Load balancing method and apparatus |
CN106453682A (en) * | 2016-10-14 | 2017-02-22 | 国网重庆市电力公司电力科学研究院 | Link layer multichannel management method |
CN106375131B (en) * | 2016-10-20 | 2019-08-02 | 浪潮电子信息产业股份有限公司 | Virtual network uplink load balancing method |
CN107968734A (en) * | 2017-11-29 | 2018-04-27 | 郑州云海信息技术有限公司 | A kind of method of the automatic test Network Packet Loss performance under network card binding pattern |
CN108259271A (en) * | 2018-02-01 | 2018-07-06 | 天津天地伟业信息系统集成有限公司 | A kind of method for detecting link state after more network card bindings by ARP |
CN108829340B (en) * | 2018-05-03 | 2021-08-17 | 北京金山安全管理系统技术有限公司 | Storage processing method, device, storage medium and processor |
US10805258B2 (en) | 2018-11-28 | 2020-10-13 | International Business Machines Corporation | Multiple link layer address resolution protocol (ARP) |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1483162A (en) * | 2000-07-27 | 2004-03-17 | BEAϵͳ��˾ | System and method for request assembling and load sharing |
CN1665236A (en) * | 2004-03-01 | 2005-09-07 | 联想(北京)有限公司 | A method for hardware address update of virtual equipment |
CN101150413A (en) * | 2007-10-31 | 2008-03-26 | 中兴通讯股份有限公司 | A kind of ATCA blade server multi-chassis cascading system and method |
-
2009
- 2009-07-17 CN CN2009100172327A patent/CN101610283B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1483162A (en) * | 2000-07-27 | 2004-03-17 | BEAϵͳ��˾ | System and method for request assembling and load sharing |
CN1665236A (en) * | 2004-03-01 | 2005-09-07 | 联想(北京)有限公司 | A method for hardware address update of virtual equipment |
CN101150413A (en) * | 2007-10-31 | 2008-03-26 | 中兴通讯股份有限公司 | A kind of ATCA blade server multi-chassis cascading system and method |
Also Published As
Publication number | Publication date |
---|---|
CN101610283A (en) | 2009-12-23 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN101610283B (en) | Method for balancing dynamic receiving load under network card binding state | |
CN109618002B (en) | Micro-service gateway optimization method, device and storage medium | |
CN108173938B (en) | Server load distribution method and device | |
CN113364624B (en) | Mixed cloud flow acquisition method and system based on edge computing | |
US20040240440A1 (en) | Virtual network addresses | |
CN102004673A (en) | Processing method and system of multi-core processor load balancing | |
CN103391299A (en) | Load balance method and load balance system | |
CN105917632A (en) | A method for scalable distributed network traffic analytics in telco | |
CN104780210A (en) | Load balancing method and device | |
CN107295036A (en) | A kind of data transmission method for uplink and data merge equipment | |
CN108881509A (en) | A kind of DNS query method and device based on HTTPDNS | |
CN105634977B (en) | It was found that the method and apparatus of Path Maximum Transmission Unit | |
CN103297282A (en) | Network delay measuring device and method | |
WO2019102911A1 (en) | Abnormal communication detection device, abnormal communication detection method, and program | |
CN106506701A (en) | A kind of server load balancing method and load equalizer | |
JP2015057931A (en) | Network apparatus, communication system, and detection method and program for abnormal traffic | |
CN103024819B (en) | Data distribution method of third-generation mobile communication core network based on user terminal IP (Internet Protocol) | |
CN103685056A (en) | Load balancing method and load balancing system | |
CN108880934A (en) | A kind of data flow statistic method and device based on block chain | |
CN103825834A (en) | Method and network exchange device for adjusting flow load sharing in EVI | |
CN109639796A (en) | A kind of implementation of load balancing, device, equipment and readable storage medium storing program for executing | |
CN114071547B (en) | QoE measurement configuration method, device and storage medium | |
CN104158675B (en) | Calculate node dispositions method, processing node, controller and system | |
CN101753639B (en) | Service role recognition method based on flow communication mode | |
CN104852859A (en) | Aggregate interface service processing method and aggregate interface service processing equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant |