Disclosure of Invention
The embodiment of the application provides a flow balancing method, a flow balancing device, electronic equipment and a storage medium, which are used for reducing the flow pressure of a network node.
The flow balancing method provided by the embodiment of the application comprises the following steps:
acquiring initial node weights corresponding to network nodes respectively, and synchronizing the initial routing weights of routers in the network nodes into corresponding initial node weights respectively;
determining the target node weight of any one network node according to the number of the main routers in any one network node when the main and standby switching of the routers in any one network node is determined;
updating the initial routing weight of each router in any network node according to the target node weight to obtain the target routing weight of each router;
and determining a main router and a standby router by routers belonging to the same switching mechanism software on different network nodes based on the mode of message interaction of respective target routing weights.
Optionally, the determining the target node weight of the arbitrary network node according to the number of the master routers in the arbitrary network node includes:
and taking the sum of the initial node weight and a routing coefficient as the target node weight, wherein the routing coefficient is the whole ratio of the number of the main routers in any network node to a preset parameter value.
Optionally, the determining the primary router and the standby router by the routers belonging to the same switching mechanism software on different network nodes based on the respective target routing weights includes:
through switching mechanism software, the routers which belong to the same switching mechanism software on different network nodes are controlled to mutually send messages carrying own target routing weight;
and determining the router identity of the message receiver according to the received comparison result of the target routing weight of the message sender and the target routing weight of the message receiver, wherein the router identity characterizes the primary and backup attributes of the message receiver.
Optionally, if the comparison result indicates that the target routing weight of the message receiver is smaller than the target routing weight of the message sender, the router identity of the message receiver is the master router;
if the comparison result shows that the target routing weight of the message receiver is greater than the target routing weight of the message sender, the router identity of the message receiver is a standby router;
and if the comparison result shows that the target routing weight of the message receiver is equal to the target routing weight of the message sender, comparing the Internet Protocol (IP) addresses of the message receiver and the message sender, wherein the router identity with larger IP address is the main router.
The flow equalization device provided in the embodiment of the application includes:
the system comprises an acquisition unit, a synchronization unit and a synchronization unit, wherein the acquisition unit is used for acquiring initial node weights corresponding to network nodes respectively and synchronizing the initial routing weights of routers in the network nodes into corresponding initial node weights respectively;
a first determining unit, configured to determine, for any one network node, a target node weight of the any one network node according to the number of the primary routers in the any one network node when a primary-backup handover occurs to a router existing in the any one network node;
the updating unit is used for updating the initial routing weight of each router in any network node according to the target node weight to obtain the target routing weight of each router;
and the second determining unit is used for determining a main router and a standby router by using routers belonging to the same switching mechanism software on different network nodes based on the mode of message interaction of respective target routing weights.
Optionally, the first determining unit is specifically configured to:
and taking the sum of the initial node weight and a routing coefficient as the target node weight, wherein the routing coefficient is the whole ratio of the number of the main routers in any network node to a preset parameter value.
Optionally, the second determining unit is specifically configured to:
through switching mechanism software, the routers which belong to the same switching mechanism software on different network nodes are controlled to mutually send messages carrying own target routing weight;
and determining the router identity of the message receiver according to the received comparison result of the target routing weight of the message sender and the target routing weight of the message receiver, wherein the router identity characterizes the primary and backup attributes of the message receiver.
Optionally, if the comparison result indicates that the target routing weight of the message receiver is smaller than the target routing weight of the message sender, the router identity of the message receiver is the master router;
if the comparison result shows that the target routing weight of the message receiver is greater than the target routing weight of the message sender, the router identity of the message receiver is a standby router;
and if the comparison result shows that the target routing weight of the message receiver is equal to the target routing weight of the message sender, comparing the Internet Protocol (IP) addresses of the message receiver and the message sender, wherein the router identity with larger IP address is the main router.
The electronic device provided by the embodiment of the application comprises a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor is caused to execute the steps of any one of the flow balancing methods.
The embodiment of the application provides a computer readable storage medium, which comprises a computer program, wherein when the program code runs on electronic equipment, the computer program is used for enabling the electronic equipment to execute the steps of any one of the flow balancing methods.
Embodiments of the present application provide a computer program product comprising a computer program stored in a computer readable storage medium; when the processor of the electronic device reads the computer program from the computer readable storage medium, the processor executes the computer program, so that the electronic device performs the steps of any one of the flow equalization methods described above.
The beneficial effects of the application are as follows:
the flow balancing method, the flow balancing device, the electronic equipment and the storage medium provided by the embodiment of the application firstly acquire initial node weights corresponding to each network node, and respectively synchronize the initial routing weights of routers in each network node into corresponding initial node weights; then, determining the target node weight of any one network node according to the number of the main routers in any one network node when the main and standby switching of the routers exists in any one network node; updating the initial routing weight of each router in any network node according to the weight of the target node to obtain the target routing weight of each router; and finally, determining a main router and a standby router by routers which are respectively assigned to the same switching mechanism software on different network nodes based on the mode of message interaction of respective target routing weights. The router weights are dynamically adjusted according to the number of the main routers on the network nodes, so that load balancing on different network nodes is realized, traffic pressure on a single network node is reduced, the problems of data packet loss and high time delay are reduced, and the bandwidth utilization rate in the network node cluster is improved.
Additional features and advantages of the application will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the application. The objectives and other advantages of the application will be realized and attained by the structure particularly pointed out in the written description and claims thereof as well as the appended drawings.
Detailed Description
For the purposes of making the objects, technical solutions and advantages of the embodiments of the present application more clear, the technical solutions of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the technical solutions of the present application, but not all embodiments. All other embodiments, which can be made by a person of ordinary skill in the art without any inventive effort, based on the embodiments described in the present application are intended to be within the scope of the technical solutions of the present application.
Some of the concepts involved in the embodiments of the present application are described below.
OpenStack (cloud computing management platform): the cloud computing management platform project is an open-source cloud computing management platform project, is a combination of a series of software open-source projects, provides extensible and elastic cloud computing service for private cloud and public cloud, and provides a cloud computing management platform which is simple to implement, can be expanded on a large scale, is rich and has unified standards.
Keepalive (switching mechanism software): the method is used for detecting the state of a server (i.e. a router), if one server is down or the work fails, keepalive will detect and reject the failed server from the system, meanwhile, other servers are used for replacing the work of the server, when the server works normally, keepalive automatically joins the server into a server group, all the works are automatically completed, manual intervention is not needed, and only the failed server is needed to be repaired manually.
And (3) a router: the network device is a hardware device connected with two or more networks, plays a role of a gateway between the networks, is a special intelligent network device for reading addresses in each data packet and then deciding how to transmit, and ensures that routers on a plurality of network nodes keep one master and multiple standby through keepalive in the application, and the internet traffic of a user flows out from the master router.
The following briefly describes the design concept of the embodiment of the present application:
with the popularization of cloud computing, openStack is widely adopted. OpenStack suffers from some drawbacks due to less experience in large-scale applications. The high availability function of OpenStack can ensure that routers on a plurality of physical machines keep a main and multi-standby mode based on keepalive exchange mechanism software, and the internet traffic of a user flows out from the main router.
In the related art, the default weight of keepalive is 50, when the high availability function is realized by keepalive, broadcasting is performed between two routers, the broadcasting message contains the weight information of keepalive, the router receiving the message compares the weight, and the router with larger weight is updated to be the main router. If the weights are equal, comparing the IP addresses of the messages sent by the keepalive, and upgrading the router with the larger IP address into the main router. However, implementing high availability based on the above manner may cause multiple primary routers to fall on the same physical machine (i.e. network node), as shown in fig. 1, where both the primary router represented by the solid line and the primary router represented by the dotted line fall on the network node 1, resulting in that the user traffic of the OpenStack cluster passes through the network node 1, and thus exceeds the maximum network load of the physical machine, resulting in problems such as packet loss, gao Shiyan, and the like.
Therefore, how to maintain the flow balance of the network nodes in the OpenStack cluster is a current urgent problem to be solved.
In view of this, the embodiments of the present application provide a flow balancing method, apparatus, electronic device, and storage medium, where initial node weights corresponding to network nodes are first obtained, and initial routing weights of routers in the network nodes are synchronized to corresponding initial node weights, respectively; then, determining the target node weight of any one network node according to the number of the main routers in any one network node when the main and standby switching of the routers exists in any one network node; updating the initial routing weight of each router in any network node according to the weight of the target node to obtain the target routing weight of each router; and finally, determining a main router and a standby router by routers which are respectively assigned to the same switching mechanism software on different network nodes based on the mode of message interaction of respective target routing weights. The router weights are dynamically adjusted according to the number of the main routers on the network nodes, so that load balancing on different network nodes is realized, traffic pressure on a single network node is reduced, the problems of data packet loss and high time delay are reduced, and the bandwidth utilization rate in the network node cluster is improved.
The preferred embodiments of the present application will be described below with reference to the accompanying drawings of the specification, it being understood that the preferred embodiments described herein are for illustration and explanation only, and are not intended to limit the present application, and embodiments and features of embodiments of the present application may be combined with each other without conflict.
Referring to fig. 2, a flow balancing method implementation flow chart provided in an embodiment of the present application is shown, where a specific implementation flow of the method is as follows:
s201: acquiring initial node weights corresponding to each network node, and synchronizing the initial routing weights of routers in each network node to the corresponding initial node weights;
the initial node weights may be set to 50, for example, in the OpenStack cluster shown in fig. 3, if the initial node weights of the network node 1 and the network node 2 are set to 50, the initial routing weights of the router 1, the router 2, the router 3 and the router 4 are all 50.
S202: determining the target node weight of any one network node according to the number of the main routers in any one network node when the main and standby switching of the routers exists in any one network node;
the primary-standby switching refers to switching of a router in a network node from a primary router to a standby router or from the standby router to the primary router.
Optionally, when any network node generates primary-standby switching, taking the sum of the initial node weight and the routing coefficient as the target node weight.
The routing coefficient is a whole ratio of the number of the main routers in any network node to a preset parameter value, and the weight of the target node can be determined by the following formula:
wherein 50 is the initial node weight, n represents the number of the main routers in any network node, k represents the preset parameter value, which can be adjusted according to the requirement,representation pair->Rounding, i.e. routing coefficients.
For example, if the number of primary routers n is 2 and k is set to 1, then the target node weight is 52.
S203: updating the initial routing weight of each router in any network node according to the target node weight to obtain the target routing weight of each router;
when the weight of any network node is updated from the initial node weight to the target node weight, the initial routing weight of the router on the corresponding network node is also updated to the target routing weight, for example, the initial node weight of the network node 1 is 50, the initial routing weights of the router 1 and the router 2 on the network node 1 are 50, and when the target node weight of the network node 1 is 52, the target routing weights of the router 1 and the router 2 are 52.
S204: and determining a main router and a standby router by routers belonging to the same switching mechanism software on different network nodes based on the mode of message interaction of respective target routing weights.
The router 1 and the router 3 in fig. 3 belong to the same switching mechanism software, and the router 1 and the router 3 can carry own target routing weight in a message interaction mode to determine whether the router is a main router or a standby router.
In the embodiment of the application, the router weight is dynamically adjusted according to the number of the main routers on the network nodes, so that load balancing on different network nodes is realized, the traffic pressure on a single network node is reduced, the problems of packet loss and high time delay of data are reduced, and the bandwidth utilization rate in the network node cluster is improved.
Optionally, step S204 is implemented based on the following steps:
firstly, through switching mechanism software, controlling routers belonging to the same switching mechanism software on different network nodes to mutually send messages carrying own target routing weight; then, determining the router identity of the message receiver according to the comparison result of the received target routing weight of the message sender and the target routing weight of the message receiver through the message receiver.
The router identity characterizes the primary and the backup attributes of the message receiver, namely the router is a primary router or a backup router.
Specifically, taking the router 1 and the router 3 as examples, the router 1 receives the message sent by the router 3, acquires the target routing weight of the router 3, the router 1 compares the target routing weight of the router with the own routing weight to determine the own active/standby attribute, and correspondingly, the router 3 receives the message sent by the router 1, acquires the target routing weight of the router 1 and compares the target routing weight with the own routing weight to determine the own active/standby attribute.
Optionally, if the comparison result indicates that the target routing weight of the message receiver is smaller than the target routing weight of the message sender, the router identity of the message receiver is the main router;
if the comparison result shows that the target routing weight of the message receiver is greater than the target routing weight of the message sender, the router identity of the message receiver is a standby router;
if the comparison result shows that the target routing weight of the message receiver is equal to the target routing weight of the message sender, comparing the Internet Protocol (IP) addresses of the message receiver and the message sender, wherein the router identity with larger IP address is the main router.
For example, the target routing weight of the router 1 is 50, the target routing weight of the router 3 is 52, the router 1 is used as a message receiver, the router 1 is determined to be a master router if the own routing weight is smaller than the target routing weight of the message sender, the router 3 is used as a message receiver, the router 3 is determined to be a standby router if the own routing weight is greater than the target routing weight of the message sender. If the target routing weights of router 1 and router 3 are equal, the IP addresses of both sides are compared, and the router identity with the larger IP address is the master router.
Referring to fig. 4, which is a flow chart of a flow balancing method in the embodiment of the present application, in conjunction with fig. 4, the flow balancing method in the present application is described below by taking the OpenStack cluster in fig. 3 as an example.
Taking the network node 1 as an example, storing all routers on the node into a cyclic connection table, determining whether the keepalive weight of the current router is equal to the weight of the current network node, if not, modifying the weight of the router so that the weight of the router is equal to the weight of the current network node, pointing to the next router, if so, directly pointing to the next router, and finally, hopefully achieving the balance of the number of the main routers on different network nodes.
For example, if the initial node weights of the network node 1 and the network node 2 are set to 50, the initial routing weights of the router 1, the router 2, the router 3, and the router 4 are all 50. When one master router is added to the network node 1, and the number of the master routers is 2, the target node weight q is 51. When the circulation connection table points to the router 1, the target routing weight 50 of the router 1 is updated to be 51, the router 1 and the router 3 send messages to each other to carry own target routing weight, the router 1 determines that the own target routing weight is greater than the target routing weight of the router 3, the router 1 is switched to a standby router, the router 3 determines that the own target routing weight is less than the target routing weight of the router 1, and the router 3 is switched to a main router.
In the embodiment of the application, by monitoring the number of routers (i.e. network nodes) on a physical machine, determining keepalive weights of the routers on the physical machine, and circularly and sequentially adjusting keepalive weights of the routers on the physical machine, finally, the balance of the number of main routers on the physical machine is expected to be achieved, so that the flow balance of the network nodes in the OpenStack cluster can be maintained, the load of the physical machine is reduced, packet loss is reduced, and the cluster bandwidth utilization rate is improved.
Based on the same inventive concept, the embodiment of the application also provides a flow balancing device. As shown in fig. 5, which is a schematic structural diagram of the flow equalization device 500, may include:
an obtaining unit 501, configured to obtain initial node weights corresponding to each network node, and synchronize initial routing weights of routers in each network node to corresponding initial node weights respectively;
a first determining unit 502, configured to determine, for any one network node, a target node weight of any one network node according to the number of the primary routers in any one network node when the primary-backup switching occurs in the router in any one network node;
an updating unit 503, configured to update an initial routing weight of each router in any one network node according to the target node weight, to obtain a target routing weight of each router;
a second determining unit 504, configured to determine, via routers belonging to the same switching mechanism software on different network nodes, a primary router and a standby router according to a manner of performing packet interaction based on respective target routing weights.
Optionally, the first determining unit 502 is specifically configured to:
taking the sum of the initial node weight and the routing coefficient as the target node weight, wherein the routing coefficient is the whole ratio of the number of the main routers in any network node to the preset parameter value.
Optionally, the second determining unit 504 is specifically configured to:
through the switching mechanism software, the routers belonging to the same switching mechanism software on different network nodes are controlled to mutually send messages carrying own target routing weight;
and determining the router identity of the message receiver according to the comparison result of the received target routing weight of the message sender and the target routing weight of the message receiver by the message receiver, wherein the router identity characterizes the primary and backup attributes of the message receiver.
Optionally, if the comparison result indicates that the target routing weight of the message receiver is smaller than the target routing weight of the message sender, the router identity of the message receiver is the main router;
if the comparison result shows that the target routing weight of the message receiver is greater than the target routing weight of the message sender, the router identity of the message receiver is a standby router;
if the comparison result shows that the target routing weight of the message receiver is equal to the target routing weight of the message sender, comparing the Internet Protocol (IP) addresses of the message receiver and the message sender, wherein the router identity with larger IP address is the main router.
For convenience of description, the above parts are described as being functionally divided into modules (or units) respectively. Of course, the functions of each module (or unit) may be implemented in the same piece or pieces of software or hardware when implementing the present application.
Those skilled in the art will appreciate that the various aspects of the present application may be implemented as a system, method, or program product. Accordingly, aspects of the present application may be embodied in the following forms, namely: an entirely hardware embodiment, an entirely software embodiment (including firmware, micro-code, etc.) or an embodiment combining hardware and software aspects may be referred to herein as a "circuit," module "or" system.
The embodiment of the application also provides electronic equipment based on the same inventive concept as the embodiment of the method. In this embodiment, the electronic device may be configured as shown in fig. 6, including a memory 601, a communication module 603, and one or more processors 602.
A memory 601 for storing a computer program for execution by the processor 602. The memory 601 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, programs required for running an instant messaging function, and the like; the storage data area can store various instant messaging information, operation instruction sets and the like.
The memory 601 may be a volatile memory (RAM) such as a random-access memory (RAM); the memory 601 may also be a nonvolatile memory (non-volatile memory), such as a read-only memory (rom), a flash memory (flash memory), a hard disk (HDD) or a Solid State Drive (SSD); or memory 601, is any other medium capable of carrying or storing a desired computer program in the form of instructions or data structures and capable of being accessed by a computer, but is not limited to such. The memory 601 may be a combination of the above memories.
The processor 602 may include one or more central processing units (central processing unit, CPU) or digital processing units, etc. A processor 602 for implementing the above-described flow balancing method when calling the computer program stored in the memory 601.
The communication module 603 is used for communicating with terminal devices and other servers.
The specific connection medium between the memory 601, the communication module 603, and the processor 602 is not limited in the embodiment of the present application. The embodiment of the present application is shown in fig. 6, where the memory 601 and the processor 602 are connected by a bus 604, and the bus 604 is shown in fig. 6 with a bold line, and the connection between other components is merely illustrative, and not limited to the above. The bus 604 may be divided into an address bus, a data bus, a control bus, and the like. For ease of description, only one thick line is depicted in fig. 6, but only one bus or one type of bus is not depicted.
The memory 601 stores a computer storage medium in which computer executable instructions are stored for implementing the flow equalization method of the embodiments of the present application. The processor 602 is configured to perform the flow equalization method described above, as shown in fig. 2.
In some possible embodiments, aspects of the flow equalization methods provided herein may also be implemented in the form of a program product comprising a computer program for causing an electronic device to perform the steps of the flow equalization methods according to the various exemplary embodiments of the present application described herein above when the program product is run on the electronic device, e.g. the electronic device may perform the steps as shown in fig. 2.
The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium can be, for example, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium would include the following: an electrical connection having one or more wires, a portable disk, a hard disk, random Access Memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
The program product of embodiments of the present application may employ a portable compact disc read only memory (CD-ROM) and comprise a computer program and may run on a computing device. However, the program product of the present application is not limited thereto, and in this document, a readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with a command execution system, apparatus, or device.
The readable signal medium may comprise a data signal propagated in baseband or as part of a carrier wave in which a readable computer program is embodied. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A readable signal medium may also be any readable medium that is not a readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with a command execution system, apparatus, or device.
A computer program embodied on a readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer programs for performing the operations of the present application may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The computer program may execute entirely on the user's computing device, partly on the user's equipment, as a stand-alone software package, partly on the user's computing device, partly on a remote computing device, or entirely on the remote computing device or server. In the case of remote computing devices, the remote computing device may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., connected via the Internet using an Internet service provider).
It should be noted that although several units or sub-units of the apparatus are mentioned in the above detailed description, such a division is merely exemplary and not mandatory. Indeed, the features and functions of two or more of the elements described above may be embodied in one element in accordance with embodiments of the present application. Conversely, the features and functions of one unit described above may be further divided into a plurality of units to be embodied.
Furthermore, although the operations of the methods of the present application are depicted in the drawings in a particular order, this is not required to or suggested that these operations must be performed in this particular order or that all of the illustrated operations must be performed in order to achieve desirable results. Additionally or alternatively, certain steps may be omitted, multiple steps combined into one step to perform, and/or one step decomposed into multiple steps to perform.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having a computer-usable computer program embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program commands may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the commands executed by the processor of the computer or other programmable data processing apparatus produce means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program commands may also be stored in a computer readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the commands stored in the computer readable memory produce an article of manufacture including command means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present application have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiments and all such alterations and modifications as fall within the scope of the application.
It will be apparent to those skilled in the art that various modifications and variations can be made in the present application without departing from the spirit or scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims and the equivalents thereof, the present application is intended to cover such modifications and variations.