Virtual machine dynamic speed limiting method, device and equipment, medium and program product
By dynamically obtaining and analyzing the traffic data of the virtual network card in the virtual switch, determining and issuing the target network speed limit value, the problem that hardware cannot achieve the common speed limit of multiple virtual network cards is solved, and the overall network speed limit and efficient utilization of resources of the virtual machine is realized.
Patent Information
- Application Number
- CN202411898037.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-04-01
AI Technical Summary
When using hardware to forward packets, the hardware cannot achieve a common speed limit for multiple devices, that is, multiple virtual network cards, resulting in the virtual machine occupying more network resources than its own resources.
By obtaining the traffic data of each virtual network card in response to the preset interval in the virtual switch, determining whether the virtual machine has exceeded the network speed limit value of the entire machine, and dynamically sending the target network speed limit value to the target speed limiter of each virtual network card based on the traffic data and the network speed limit value of the entire machine, so as to achieve the network speed limit of the virtual machine.
The network speed limit of the entire network for virtual machines with multiple virtual network cards is achieved, avoiding excessive consumption of network resources and improving the efficiency of network resources utilization.
Smart Images

Figure CN119743396A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of virtual machine technology, and in particular to a method, device, equipment, medium and program product for dynamic speed limiting of a virtual machine. Background Art
[0002] With the development of virtual network technology, it has become an industry consensus to use a software-hardware collaborative architecture to improve network performance. Although different manufacturers have different implementation methods, they are essentially to offload network message forwarding from software to hardware to fully utilize the high performance of hardware forwarding.
[0003] In the existing software and hardware collaborative architecture, message forwarding can be performed by setting up software in the host machine or by hardware. When multiple virtual network cards are deployed on the virtual machine corresponding to the host machine and message forwarding is performed through software, each message will pass through the software, so as long as a speed limiter is set on the software and multiple virtual network cards on the same virtual machine are bound to the same speed limiter, the speed limit of the entire machine can be achieved.
[0004] However, after the introduction of hardware acceleration, that is, when hardware is used for message forwarding, the hardware cannot achieve common speed limit for multiple devices, that is, multiple virtual network cards. Each virtual network card is limited according to the speed limit of the entire machine, which causes the network resources occupied by the virtual machine to exceed its own resources. Therefore, when hardware is used for message forwarding, how to achieve speed limit for virtual machines with multiple virtual network cards is a technical problem that needs to be solved urgently. Summary of the invention
[0005] In order to solve the above technical problems, the present disclosure provides a method, device, equipment, medium and program product for dynamically limiting the speed of a virtual machine.
[0006] A first aspect of an embodiment of the present disclosure provides a method for dynamic speed limiting of a virtual machine, which is applied to a virtual switch in a host machine, wherein at least one virtual network card is provided on a virtual machine corresponding to the host machine, and includes:
[0007] In response to a preset time interval, obtaining flow data corresponding to each virtual network card;
[0008] Determine whether the virtual machine exceeds the network speed limit of the entire machine based on traffic data;
[0009] When it is determined that the virtual machine exceeds the network speed limit of the entire machine, the target network speed limit corresponding to each virtual network card is determined based on the traffic data and the network speed limit of the entire machine;
[0010] The target network speed limit value is sent to the target speed limiter corresponding to each virtual network card, so that the target speed limiter limits the speed of the virtual network card based on the target network speed limit value, thereby limiting the network speed of the entire virtual machine.
[0011] A second aspect of an embodiment of the present disclosure provides a virtual machine dynamic speed limiting device, which is applicable to a virtual switch in a host machine, and a virtual machine corresponding to the host machine is provided with at least one virtual network card, including:
[0012] A data acquisition module, used to acquire the flow data corresponding to each virtual network card in response to a preset interval time;
[0013] A speed limit judgment module is used to determine whether the virtual machine exceeds the speed limit of the entire network based on traffic data;
[0014] A speed limit value determination module is used to determine the target network speed limit value corresponding to each virtual network card based on traffic data and the network speed limit value of the entire machine when it is determined that the virtual machine exceeds the network speed limit value of the entire machine;
[0015] The speed limit execution module is used to send the target network speed limit value to the target speed limiter corresponding to each virtual network card, so that the target speed limiter limits the speed of the virtual network card based on the target network speed limit value, so as to limit the network speed of the entire virtual machine.
[0016] A third aspect of the embodiments of the present disclosure provides an electronic device, including:
[0017] processor;
[0018] A memory for storing executable instructions;
[0019] The processor is used to read executable instructions from the memory and execute the executable instructions to implement the virtual machine dynamic speed limiting method provided in the first aspect.
[0020] A fourth aspect of an embodiment of the present disclosure provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the processor implements the virtual machine dynamic speed limiting method provided in the first aspect.
[0021] A fifth aspect of an embodiment of the present disclosure provides a computer program product, which includes a computer program or instructions. When the computer program or instructions are executed by a processor, the method for dynamic speed limiting of a virtual machine as described in the first aspect above is implemented.
[0022] Compared with the prior art, the technical solution provided by the embodiments of the present disclosure has the following advantages:
[0023] The virtual machine dynamic speed limit method, device, equipment, medium and program product provided by the embodiments of the present disclosure can obtain the traffic data corresponding to each virtual network card in response to a preset interval time, and after obtaining the traffic data, determine whether the virtual machine exceeds the network speed limit value of the entire machine based on the traffic data. When it is determined that the virtual machine exceeds the network speed limit of the entire machine, the target network speed limit corresponding to each virtual network card is determined based on the traffic data and the network speed limit of the entire machine, and the target network speed limit is sent to the target speed limiter corresponding to each virtual network card, so that the target speed limiter limits the speed of the virtual network card based on the target network speed limit, so as to limit the network speed of the entire machine for the virtual machine. In this way, the network status of each virtual network card can be monitored through the virtual switch, and the acquired traffic data can be analyzed to determine whether the virtual machine exceeds the network speed limit of the entire machine. If the network speed limit of the entire machine is exceeded, the target network speed limit corresponding to each virtual network card is allocated according to the traffic data and the network speed limit of the entire machine corresponding to each virtual network card, and the target network speed limit is dynamically sent to the target speed limiter in the hardware, so that the target speed limiter limits the network speed of the corresponding virtual network card according to the target network speed limit, thereby realizing the network speed limit of the entire machine of the virtual machine. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0025] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0026] Figure 1 is a flow chart of a method for dynamic speed limiting of a virtual machine provided by an embodiment of the present disclosure;
[0027] Figure 2 is a schematic diagram of an application scenario provided by an embodiment of the present disclosure;
[0028] Figure 3 is a flow chart of another method for dynamic speed limiting of a virtual machine provided by an embodiment of the present disclosure;
[0029] Figure 4 It is a structural schematic diagram of a virtual machine dynamic speed limiting device provided by an embodiment of the present disclosure;
[0030] Figure 5 It is a structural schematic diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0031] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0032] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0033] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0034] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0035] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0036] Generally, after the introduction of hardware acceleration, that is, when hardware is used for message forwarding, the hardware cannot achieve the common speed limit for multiple devices, that is, multiple virtual network cards. Each virtual network card is speed-limited according to the speed limit value of the entire machine, which causes the network resources occupied by the virtual machine to exceed its own resources. Therefore, when hardware is used for message forwarding, how to achieve virtual machine speed limit for multiple virtual network cards is a technical problem that needs to be solved urgently. In response to this problem, the embodiments of the present disclosure provide a method for dynamic speed limit of a virtual machine, which is introduced below in conjunction with specific embodiments.
[0037] Figure 1The present invention provides a flowchart of a virtual machine dynamic speed limiting method provided by an embodiment of the present invention. The method can be executed by a virtual machine dynamic speed limiting device. The virtual machine dynamic speed limiting device can be implemented in software and / or hardware. The virtual machine dynamic speed limiting device can be configured in an electronic device, such as a server or a terminal, wherein the terminal specifically includes a mobile phone, a computer or a tablet computer, etc. In addition, the method can be applied to Figure 2 The application scenario shown includes a host machine, which includes software, hardware and physical interfaces. When a message needs to be forwarded, it is received through the physical interface on the host and sent to the hardware, which forwards it. It can be understood that the virtual machine dynamic speed limit method provided in the embodiment of the present disclosure can also be applied in other scenarios.
[0038] like Figure 2 As shown, the software can be a virtual switch, which can be used to obtain the traffic data of each virtual network card and perform dynamic speed limiting of the virtual machine based on the traffic data. A virtual switch is a network component that implements the switch function at the software level. The virtual switch simulates the behavior of a physical switch through software, including packet forwarding, filtering, address learning, etc. It can create and manage virtual LANs in a virtualized environment, implement network traffic isolation and load balancing, and other network functions.
[0039] The hardware can be a network card, such as a data processor, etc.; multiple speed limiters are set on the hardware, such as speed limiter 1, speed limiter 2, speed limiter 3 and speed limiter 4, and the multiple speed limiters correspond to the virtual network cards one by one, such as speed limiter 1 corresponds to virtual network card 1, speed limiter 2 corresponds to virtual network card 2, speed limiter 3 corresponds to virtual network card 3, and speed limiter 4 corresponds to virtual network card 4, wherein the virtual network card is the virtual network card on the virtual machine corresponding to the host machine, and the number of virtual network cards can be flexibly set according to demand. Of course, the number of speed limiters can also be flexibly set according to the number of virtual network cards.
[0040] Combine the following Figure 2 The application scenario shown is Figure 1 The virtual machine dynamic speed limit method shown in the figure is introduced. For example, Figure 2 The software in the virtual switch can perform this method. Figure 1 As shown, the virtual machine dynamic speed limiting method provided in this embodiment includes the following steps.
[0041] S110. In response to a preset time interval, obtain traffic data corresponding to each virtual network card.
[0042] In the embodiment of the present disclosure, the preset time may be preset according to the demand. For example, the preset time may be 5 seconds.
[0043] Traffic data can be understood as data used to characterize the network card rate of the virtual network card, which can specifically include the number of message forwardings and the number of forwarded bytes corresponding to each virtual network card within a preset time. In the embodiment of the present disclosure, the network card rate of the virtual network card is characterized by the number of message forwardings and the number of forwarded bytes. Of course, in actual use, other parameters can be used to characterize the network card rate.
[0044] Specifically, the virtual switch uses a preset tool to obtain the flow data corresponding to each virtual network card on the virtual machine in response to the preset time interval. The preset tool can be a flow monitoring tool, a management tool of the virtualization platform, a counter, etc., which is not limited here.
[0045] S120: Determine whether the virtual machine exceeds the network speed limit of the entire machine based on the traffic data.
[0046] In the embodiment of the present disclosure, the whole machine network speed limit value can be understood as a value used to limit the speed of the whole machine network of the virtual machine, which can be the whole machine maximum rate of the virtual machine; specifically, it can include the whole machine message forwarding threshold and the whole machine forwarding byte threshold.
[0047] The whole-machine packet forwarding threshold and the whole-machine forwarding byte threshold may be the maximum number of packets and the maximum number of bytes that the whole virtual machine can forward per second.
[0048] Specifically, after obtaining the traffic data corresponding to each virtual network card, the virtual switch calculates the sum of the network card rates of each virtual network card based on the traffic data of at least one virtual network card corresponding to the virtual machine, compares the sum of the network card rates with the network speed limit of the entire machine, and determines whether the virtual machine exceeds the network speed limit of the entire machine based on the comparison result.
[0049] S130: When it is determined that the virtual machine exceeds the network speed limit of the entire machine, determine a target network speed limit corresponding to each virtual network card based on the traffic data and the network speed limit of the entire machine.
[0050] In the embodiment of the present disclosure, the target network speed limit value can be understood as the maximum number of packets and the maximum number of bytes that the virtual network card can forward per second.
[0051] Specifically, when the virtual switch determines that the virtual machine exceeds the network speed limit of the entire machine, it means that the network speed limit needs to be performed on each virtual network card. Therefore, the excess ratio is determined based on the sum of the traffic data corresponding to at least one virtual network card and the network speed limit of the entire machine, and then the target network speed limit corresponding to each virtual network card is determined based on the excess ratio and the traffic data of each virtual network card.
[0052] S140: Send the target network speed limit value to the target speed limiter corresponding to each virtual network card, so that the target speed limiter limits the speed of the virtual network card based on the target network speed limit value, so as to limit the network speed of the entire virtual machine.
[0053] Specifically, after obtaining the target network speed limit value corresponding to each virtual network card, the virtual switch sends the target network speed limit value to the target speed limiter corresponding to each virtual network card, so that the target speed limiter limits the speed of the virtual network card based on the target network speed limit value, that is, discards the messages of the virtual network card that exceed the speed limit value, so as to achieve the whole network speed limit of the virtual machine by limiting the speed of each virtual network card.
[0054] In the disclosed embodiment, the flow data corresponding to each virtual network card can be obtained in response to a preset time interval, and after the flow data is obtained, it is determined whether the virtual machine exceeds the network speed limit of the entire machine based on the flow data. When it is determined that the virtual machine exceeds the network speed limit of the entire machine, the target network speed limit corresponding to each virtual network card is determined based on the traffic data and the network speed limit of the entire machine, and the target network speed limit is sent to the target speed limiter corresponding to each virtual network card, so that the target speed limiter limits the speed of the virtual network card based on the target network speed limit, so as to limit the network speed of the entire machine for the virtual machine. In this way, the network status of each virtual network card can be monitored through the virtual switch, and the acquired traffic data can be analyzed to determine whether the virtual machine exceeds the network speed limit of the entire machine. If the network speed limit of the entire machine is exceeded, the target network speed limit corresponding to each virtual network card is allocated according to the traffic data and the network speed limit of the entire machine corresponding to each virtual network card, and the target network speed limit is dynamically sent to the target speed limiter in the hardware, so that the target speed limiter limits the network speed of the corresponding virtual network card according to the target network speed limit, thereby realizing the network speed limit of the entire machine of the virtual machine.
[0055] Based on the above embodiments of the present disclosure, before obtaining the traffic data corresponding to each virtual network card in response to a preset interval time, the virtual machine dynamic speed limiting method may also include: in response to the startup of the virtual machine, initializing the target speed limiter corresponding to each virtual network card based on the network speed limit value of the entire machine.
[0056] Specifically, in response to the startup of the virtual machine, the virtual switch obtains the entire network speed limit value of the virtual machine, and sends the entire network speed limit value of the virtual machine to the target speed limiter corresponding to each virtual network card, so that the target speed limiter limits the speed of the corresponding virtual network card based on the entire network speed limit value, thereby completing the initialization setting of the target speed limiter.
[0057] In the disclosed embodiment, in response to the virtual machine starting, the target speed limiter corresponding to each virtual network card in the hardware can be initialized and set, thereby providing a guarantee for the normal operation of the target speed limiter.
[0058] In an embodiment of the present disclosure, determining whether a virtual machine exceeds the network speed limit of the entire machine based on traffic data may specifically include: calculating based on the number of message forwardings and a preset time to obtain a target number of message forwardings per second for each virtual network card, and calculating based on the number of forwarded bytes and a preset time to obtain a target number of forwarded bytes per second for each virtual network card; determining whether the virtual machine exceeds the network speed limit of the entire machine based on the target number of message forwardings, the target number of forwarded bytes, the message forwarding threshold of the entire machine, and the forwarding byte threshold of the entire machine.
[0059] Specifically, after obtaining the traffic data, the virtual switch obtains the number of packet forwardings and the number of forwarded bytes in the traffic data, and divides the number of packet forwardings by the preset time to obtain the target number of packet forwardings per second for each virtual network card. At the same time, the number of forwarded bytes is divided by the preset time to obtain the target number of forwarded bytes per second for each virtual network card, and then determines whether the virtual machine exceeds the network speed limit of the entire machine based on the target number of packet forwardings, the target number of forwarded bytes, the entire machine packet forwarding threshold and the entire machine forwarding byte threshold.
[0060] Further, determining whether the virtual machine exceeds the network speed limit of the entire machine based on the target message forwarding number, the target forwarding byte number, the entire machine message forwarding threshold and the entire machine forwarding byte threshold may specifically include: when the sum of the target message forwarding numbers corresponding to at least one virtual network card corresponding to the virtual machine is greater than the message forwarding threshold of the entire machine, and / or the sum of the target forwarding bytes corresponding to at least one virtual network card corresponding to the virtual machine is greater than the entire machine forwarding byte threshold, determining that the virtual machine exceeds the network speed limit of the entire machine.
[0061] Specifically, the virtual switch adds the target message forwarding numbers corresponding to each virtual network card to obtain the sum of the target message forwarding numbers, and then compares the sum of the target message forwarding numbers with the message forwarding threshold of the entire machine to obtain a first comparison result. At the same time, the target forwarding byte numbers corresponding to each virtual network card are added to obtain the sum of the target forwarding byte numbers, and then the sum of the target forwarding byte numbers is compared with the forwarding byte threshold of the entire machine to obtain a second comparison result. When the first comparison result is that the sum of the target message forwarding numbers is greater than the message forwarding threshold of the entire machine, and / or the sum of the target forwarding byte numbers is greater than the forwarding byte threshold of the entire machine, it is determined that the virtual machine exceeds the network speed limit of the entire machine; otherwise, it is determined that the virtual machine does not exceed the network speed limit of the entire machine.
[0062] In the disclosed embodiment, whether the virtual machine exceeds the network speed limit of the entire machine can be determined by the sum of the target message forwarding numbers and the sum of the target forwarding bytes of each virtual network card, thereby improving the accuracy of determining whether the virtual machine exceeds the network speed limit of the entire machine.
[0063] In an embodiment of the present disclosure, when it is determined that a virtual machine exceeds the network speed limit value of the entire machine, a target network speed limit value corresponding to each virtual network card is determined based on traffic data and the network speed limit value of the entire machine, which may specifically include: determining a first excess ratio based on a target message forwarding number and a message forwarding threshold of the entire machine, and determining a second excess ratio based on a target number of forwarded bytes and a forwarding byte threshold of the entire machine; calculating a first product of the first excess ratio and the target message forwarding number, determining the first product as the message forwarding speed limit value, and calculating a second product of the second excess ratio and the target number of forwarded bytes, determining the second product as the forwarding byte speed limit value; determining the message forwarding speed limit value and the forwarding byte speed limit value as the target network speed limit value.
[0064] The first over-limit ratio is determined based on the target message forwarding number and the whole-machine message forwarding threshold, including: determining the first over-limit ratio as the ratio of the whole-machine message forwarding threshold to the sum of the target message forwarding numbers of each virtual network card.
[0065] Determining the second over-limit ratio based on the target forwarding byte number and the whole machine forwarding byte threshold includes: determining the second over-limit ratio as the ratio of the whole machine forwarding byte threshold to the sum of the target forwarding byte numbers of each virtual network card.
[0066] Exemplarily, the bandwidth of the virtual machine is 1G, that is, the network speed limit value of the entire machine is 1G, and the virtual machine is bound to 4 virtual network cards.
[0067] After booting, the virtual switch vswitch sends a speed limit of 1G bandwidth to each virtual network card, that is, initializes the target speed limiter corresponding to the virtual network card. Figure 2 The speed limit values set for speed limiter 1, speed limiter 2, speed limiter 3 and speed limiter 4 are all 1G.
[0068] Then, the virtual switch vswitch calculates the network card rate of each network card in real time or at preset intervals. If in the first time interval, the network card rates of each virtual network card are: 100M / 100M / 200M / 300M, and the sum is 700M, which is less than 1G, then no change is made, and the traffic data of each network card is continued to be monitored to calculate the network card rate of each network card; if in a subsequent time interval, the network card rates of each virtual network card are: 300M / 300M / 700M / 700M, and the sum is 2 G, greater than 1G, at this time, the ratio of the whole network speed limit value 1G to the sum of the network card rates of each virtual network card 2G is calculated to get 0.5, which is determined as the over-limit ratio, and the over-limit ratio is multiplied by the network card rate of each virtual network card to get the target speed limit value, which is 150M / 150M / 350M / 350M respectively. Then, the target speed limit value 150M / 150M / 350M / 350M is sent to the target speed limiter corresponding to the virtual network card in the hardware, so that the target speed limiter limits the speed of the virtual network card based on the target speed limit value. This cycle is repeated, so that the sum of the speed limiters will always remain as the whole machine speed limit value, but for a single virtual network card, its speed limit value will continue to be dynamically adjusted according to the actual operation situation, thereby realizing the whole machine dynamic speed limit of multiple virtual network cards based on hardware.
[0069] In the disclosed embodiments, the speed limit value corresponding to each virtual network card can be dynamically adjusted according to the actual operation of the virtual network card, thereby improving the flexibility and accuracy of the speed limit of the virtual network card and realizing hardware-based dynamic speed limit of multiple virtual network cards for the entire machine.
[0070] Figure 3 is a flow chart of another method for dynamic speed limiting of a virtual machine provided by an embodiment of the present disclosure. Figure 3 As shown, the virtual machine dynamic speed limiting method may include the following steps:
[0071] S310: In response to the virtual machine starting up, a target speed limiter corresponding to each virtual network card is initialized and set based on the speed limit value of the entire network.
[0072] S320: After the initialization setting is completed, in response to the preset time interval, obtain the traffic data corresponding to each virtual network card.
[0073] S330: Determine whether the virtual machine exceeds the network speed limit of the entire machine based on the traffic data.
[0074] In the embodiment of the present disclosure, when it is determined that the virtual machine exceeds the network speed limit of the entire machine, steps S340-S350 are executed; when it is determined that the virtual machine does not exceed the network speed limit of the entire machine, step S360 is executed.
[0075] S340: When it is determined that the virtual machine exceeds the network speed limit of the entire machine, determine the target network speed limit corresponding to each virtual network card based on the traffic data and the network speed limit of the entire machine.
[0076] S350: Send the target network speed limit value to the target speed limiter corresponding to each virtual network card, so that the target speed limiter limits the speed of the virtual network card based on the target network speed limit value, so as to limit the network speed of the entire virtual machine.
[0077] S360: When it is determined that the virtual machine does not exceed the network speed limit of the entire machine, continue to obtain the target traffic data corresponding to each virtual network card at a preset interval to perform a dynamic speed limit operation on the virtual machine based on the target traffic data.
[0078] It should be noted that the specific implementation of steps S310-S360 is similar to the specific implementation of the relevant steps in the above embodiments of the present disclosure, and will not be repeated here.
[0079] In the embodiments of the present disclosure, the network status of each virtual network card can be monitored through the virtual switch, and the acquired traffic data can be analyzed to determine whether the virtual machine exceeds the network speed limit of the entire machine. If it exceeds the network speed limit of the entire machine, the target network speed limit value corresponding to each virtual network card is allocated according to the traffic data corresponding to each virtual network card and the network speed limit value of the entire machine, and it is dynamically sent to the target speed limiter in the hardware, so that the target speed limiter limits the network speed of the corresponding virtual network card according to the target network speed limit value, and dynamically adjusts the speed limit value corresponding to each virtual network card according to the actual operation of the virtual network card, thereby improving the flexibility and accuracy of the speed limit of the virtual network card, and realizing the dynamic speed limit of the entire machine of multiple virtual network cards based on hardware.
[0080] Figure 4 It is a structural diagram of a virtual machine dynamic speed limiting device provided by an embodiment of the present disclosure.
[0081] In the disclosed embodiment, the virtual machine dynamic speed limiting device is applicable to a virtual switch in a host machine, and at least one virtual network card is provided on the virtual machine corresponding to the host machine, which can be provided in an electronic device and is understood as a part of the functional modules in the above electronic device. Specifically, the electronic device can be a server or a terminal, wherein the terminal specifically includes a mobile phone, a computer or a tablet computer, etc., which is not limited here.
[0082] like Figure 4 As shown, the virtual machine dynamic speed limit device 400 may include a data acquisition module 410 , a speed limit judgment module 420 , a speed limit value determination module 430 and a speed limit execution module 440 .
[0083] The data acquisition module 410 may be configured to acquire the flow data corresponding to each virtual network card in response to a preset time interval.
[0084] The speed limit determination module 420 may be used to determine whether the virtual machine exceeds the speed limit of the entire network based on the traffic data.
[0085] The speed limit value determination module 430 can be used to determine the target network speed limit value corresponding to each virtual network card based on traffic data and the network speed limit value of the entire machine when it is determined that the virtual machine exceeds the network speed limit value of the entire machine.
[0086] The speed limit execution module 440 can be used to send the target network speed limit value to the target speed limiter corresponding to each virtual network card, so that the target speed limiter limits the speed of the virtual network card based on the target network speed limit value, thereby limiting the network speed of the entire virtual machine.
[0087] In the disclosed embodiment, the flow data corresponding to each virtual network card can be obtained in response to a preset time interval, and after the flow data is obtained, it is determined whether the virtual machine exceeds the network speed limit of the entire machine based on the flow data. When it is determined that the virtual machine exceeds the network speed limit of the entire machine, the target network speed limit corresponding to each virtual network card is determined based on the traffic data and the network speed limit of the entire machine, and the target network speed limit is sent to the target speed limiter corresponding to each virtual network card, so that the target speed limiter limits the speed of the virtual network card based on the target network speed limit, so as to limit the network speed of the entire machine for the virtual machine. In this way, the network status of each virtual network card can be monitored through the virtual switch, and the acquired traffic data can be analyzed to determine whether the virtual machine exceeds the network speed limit of the entire machine. If the network speed limit of the entire machine is exceeded, the target network speed limit corresponding to each virtual network card is allocated according to the traffic data and the network speed limit of the entire machine corresponding to each virtual network card, and the target network speed limit is dynamically sent to the target speed limiter in the hardware, so that the target speed limiter limits the network speed of the corresponding virtual network card according to the target network speed limit, thereby realizing the network speed limit of the entire machine of the virtual machine.
[0088] In some embodiments of the present disclosure, the virtual machine dynamic speed limiting device 400 may further include an initialization module.
[0089] The initialization module can be used to initialize the target speed limiter corresponding to each virtual network card based on the whole machine network speed limit value in response to the virtual machine startup before obtaining the traffic data corresponding to each virtual network card in response to the preset interval time.
[0090] In some embodiments of the present disclosure, traffic data includes the number of message forwardings and the number of forwarded bytes corresponding to each virtual network card within a preset time; the whole machine network speed limit value includes the whole machine message forwarding threshold and the whole machine forwarding byte threshold.
[0091] The speed limit determination module 420 may be specifically configured to calculate based on the number of message forwardings and the preset time to obtain the target number of message forwardings per second for each virtual network card, and to calculate based on the number of forwarded bytes and the preset time to obtain the target number of forwarded bytes per second for each virtual network card;
[0092] Determine whether the VM exceeds the network rate limit of the entire machine based on the target number of forwarded packets, the target number of forwarded bytes, the entire machine packet forwarding threshold, and the entire machine forwarding byte threshold.
[0093] In some embodiments of the present disclosure, the speed limit judgment module 420 can also be specifically used to determine that the virtual machine exceeds the network speed limit of the entire machine when the sum of the target message forwarding numbers corresponding to at least one virtual network card corresponding to the virtual machine is greater than the message forwarding threshold of the entire machine, and / or the sum of the target forwarding bytes corresponding to at least one virtual network card corresponding to the virtual machine is greater than the forwarding byte threshold of the entire machine.
[0094] In some embodiments of the present disclosure, the rate limit value determination module 430 may be specifically configured to determine a first over-limit ratio based on a target message forwarding number and a whole machine message forwarding threshold, and determine a second over-limit ratio based on a target forwarding byte number and a whole machine forwarding byte threshold;
[0095] Calculate a first product of a first excess ratio and a target number of forwarded packets, determine the first product as a packet forwarding rate limit value, and calculate a second product of a second excess ratio and a target number of forwarded bytes, determine the second product as a forwarding byte rate limit value;
[0096] The message forwarding rate limit value and the forwarding byte rate limit value are determined as the target network rate limit value.
[0097] In some embodiments of the present disclosure, the virtual machine dynamic speed limiting device 400 may further include an information processing module.
[0098] The information processing module can be used to determine whether the virtual machine exceeds the network speed limit of the entire machine based on the traffic data. When it is determined that the virtual machine does not exceed the network speed limit of the entire machine, the information processing module continues to obtain the target traffic data corresponding to each virtual network card at a preset interval to perform dynamic speed limit operations on the virtual machine based on the target traffic data.
[0099] It should be noted that Figure 4 The virtual machine dynamic speed limiting device 400 shown can execute each step in the above method embodiment and realize each process and effect in the above method embodiment, which will not be described in detail here.
[0100] Figure 5 It is a structural schematic diagram of an electronic device provided by an embodiment of the present disclosure.
[0101] In the disclosed embodiment, Figure 5The electronic device shown may be a server or a terminal, wherein the terminal specifically includes a mobile phone, a computer or a tablet computer, etc., which is not limited here.
[0102] like Figure 5 As shown, the electronic device may include a processor 510 and a memory 520 storing computer program instructions.
[0103] Specifically, the processor 510 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present disclosure.
[0104] The memory 520 may include a large capacity memory for information or instructions. By way of example and not limitation, the memory 520 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a tape, or a universal serial bus (USB) drive, or a combination of two or more of these. Where appropriate, the memory 520 may include a removable or non-removable (or fixed) medium. Where appropriate, the memory 520 may be inside or outside the integrated gateway device. In a particular embodiment, the memory 520 is a non-volatile solid-state memory. In a particular embodiment, the memory 520 includes a read-only memory (ROM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (Electrically Erasable Programmable ROM, EEPROM), an electrically rewritable ROM (EAROM), or a flash memory, or a combination of two or more of these.
[0105] The processor 510 reads and executes the computer program instructions stored in the memory 520 to perform the steps of the method for dynamic speed limiting of a virtual machine provided in the embodiment of the present disclosure.
[0106] In one example, the electronic device may further include a transceiver 530 and a bus 540. Figure 5 As shown, the processor 510, the memory 520 and the transceiver 530 are connected via a bus 540 and communicate with each other.
[0107] The bus 540 includes hardware, software, or both. For example, but not limitation, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industrial Standard Architecture (ISA) bus, an InfiniBand interconnect, a Low Pin Count (LPC) bus, a Memory bus, a MicroChannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or other suitable buses or a combination of two or more of these. Where appropriate, the bus 540 may include one or more buses.
[0108] The embodiment of the present disclosure further provides a computer-readable storage medium, which may store a computer program. When the computer program is executed by a processor, the processor implements the virtual machine dynamic speed limiting method provided by the embodiment of the present disclosure.
[0109] The above-mentioned storage medium may, for example, include a memory 520 of computer program instructions, and the above-mentioned instructions may be executed by the processor 510 of the electronic device to complete the virtual machine dynamic speed limiting method provided in the embodiment of the present disclosure. Optionally, the storage medium may be a non-temporary computer-readable storage medium, for example, the non-temporary computer-readable storage medium may be a ROM, a random access memory (Random Access Memory, RAM), a compact disc read-only memory (Compact Disc ROM, CD-ROM), a magnetic tape, a floppy disk, and an optical data storage device, etc.
[0110] The embodiments of the present disclosure also provide a computer program product, which includes a computer program or instructions. When the computer program or instructions are executed by a processor, the virtual machine dynamic speed limiting method provided by the embodiments of the present disclosure is implemented, and the various processes and effects in the above embodiments of the present disclosure can be implemented, which will not be repeated here.
[0111] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for dynamic speed limiting of a virtual machine, characterized in that: A virtual switch applied to a host machine, wherein at least one virtual network card is provided on a virtual machine corresponding to the host machine, including: In response to a preset time interval, obtaining flow data corresponding to each virtual network card; Determining whether the virtual machine exceeds the network speed limit of the entire machine based on the traffic data; When it is determined that the virtual machine exceeds the network speed limit value of the entire machine, determining a target network speed limit value corresponding to each virtual network card based on the traffic data and the network speed limit value of the entire machine; The target network speed limit value is sent to the target speed limiter corresponding to each virtual network card, so that the target speed limiter limits the speed of the virtual network card based on the target network speed limit value, so as to limit the entire network speed of the virtual machine.
2. The method according to claim 1, characterized in that Before obtaining the flow data corresponding to each virtual network card in response to the preset time interval, the method further includes: In response to the virtual machine starting up, a target speed limiter corresponding to each virtual network card is initialized and set based on the whole machine network speed limit value.
3. The method according to claim 1, characterized in that The traffic data includes the number of message forwardings and the number of forwarding bytes corresponding to each virtual network card within the preset time; the whole machine network speed limit value includes the whole machine message forwarding threshold and the whole machine forwarding byte threshold; The determining, based on the traffic data, whether the virtual machine exceeds the network speed limit of the entire machine includes: Calculating based on the number of message forwardings and the preset time to obtain a target number of message forwardings per second for each virtual network card, and calculating based on the number of forwarded bytes and the preset time to obtain a target number of forwarded bytes per second for each virtual network card; It is determined whether the virtual machine exceeds the whole machine network speed limit value based on the target message forwarding number, the target forwarding byte number, the whole machine message forwarding threshold and the whole machine forwarding byte threshold.
4. The method according to claim 3, characterized in that The determining whether the virtual machine exceeds the whole machine network speed limit value based on the target message forwarding number, the target forwarding byte number, the whole machine message forwarding threshold and the whole machine forwarding byte threshold includes: When the sum of the target message forwarding numbers corresponding to at least one virtual network card corresponding to the virtual machine is greater than the whole machine message forwarding threshold, and / or the sum of the target forwarding byte numbers corresponding to at least one virtual network card corresponding to the virtual machine is greater than the whole machine forwarding byte threshold, it is determined that the virtual machine exceeds the whole machine network speed limit value.
5. The method according to claim 3, characterized in that: When determining that the virtual machine exceeds the network speed limit value of the entire machine, determining a target network speed limit value corresponding to each virtual network card based on the traffic data and the network speed limit value of the entire machine includes: Determine a first over-limit ratio based on the target message forwarding number and the whole machine message forwarding threshold, and determine a second over-limit ratio based on the target forwarding byte number and the whole machine forwarding byte threshold; Calculate a first product of the first over-limit ratio and the target number of forwarded packets, determine the first product as the packet forwarding rate limit value, and calculate a second product of the second over-limit ratio and the target number of forwarded bytes, and determine the second product as the forwarding byte rate limit value; The message forwarding rate limit value and the forwarding byte rate limit value are determined as the target network rate limit value.
6. The method according to claim 1, characterized in that After determining whether the virtual machine exceeds the network speed limit of the entire machine based on the traffic data, the method further includes: When it is determined that the virtual machine does not exceed the whole machine network speed limit value, the target traffic data corresponding to each virtual network card continues to be obtained at intervals of the preset time, so as to perform a dynamic speed limit operation on the virtual machine based on the target traffic data.
7. A virtual machine dynamic speed limiting device, characterized in that: Applicable to a virtual switch in a host machine, wherein at least one virtual network card is provided on a virtual machine corresponding to the host machine, including: A data acquisition module, used to acquire the flow data corresponding to each virtual network card in response to a preset interval time; A speed limit judgment module, used to determine whether the virtual machine exceeds the speed limit of the entire network based on the traffic data; A speed limit value determination module, configured to determine a target network speed limit value corresponding to each virtual network card based on the traffic data and the network speed limit value of the entire machine when it is determined that the virtual machine exceeds the network speed limit value of the entire machine; The speed limit execution module is used to send the target network speed limit value to the target speed limiter corresponding to each virtual network card, so that the target speed limiter limits the speed of the virtual network card based on the target network speed limit value, so as to limit the speed of the entire virtual machine network.
8. An electronic device, characterized in that: include: processor; A memory for storing executable instructions; The processor is used to read the executable instructions from the memory and execute the executable instructions to implement the virtual machine dynamic speed limiting method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by the processor, the processor implements the method for dynamic speed limiting of a virtual machine according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program or instructions, characterized in that: When the computer program or instruction is executed by a processor, the method for dynamic speed limiting of a virtual machine according to any one of claims 1 to 6 is implemented.
Citation Information
Cited By
Speed-limiting configuration method, device and equipment of virtual switch, medium and product
CN120880998A