Traffic Shaping
Traffic shaping is the ability to control the quantity of traffic that is allowed to flow across a link. That is, rather than letting the traffic go as fast as it possibly can, you can set limits to how much traffic can be sent.
Within a standard vSwitch, you can only enforce traffic shaping on outbound traffic that is being sent out of an object—such as a VM or VMkernel port—toward another object. This is referred to by VMware as “ingress traffic” and refers to the fact that data is coming into the vSwitch by way of the virtual ports. Later, we cover how to set “egress traffic” shaping, which is the control of traffic being received by a port group headed toward a VM or VMkernel port, when we start talking about the distributed switch in the next chapter.
Traffic shaping consists of three different control points, as shown in Figure 8.6.
Figure 8.6 A look at the traffic-shaping controls
- Average bandwidth (Kbps): The average amount of bandwidth, measured in kilobits per second (Kbps), that you allow the switch to send. There might be short periods where the traffic slightly exceeds this value, since it is an average over time, but for the most part, it will be enforced and traffic will go no faster than the defined speed limit set here.
Peak bandwidth (Kbps): The maximum amount of bandwidth that the switch is allowed to let through. The use of the peak bandwidth value is determined by how often we’ve hit the average bandwidth limitation. Whenever the actual traffic volume is lower than the average bandwidth limit, we gain what is called a “burst bonus” which can be any number of bytes up to the limit set by the burst size value (covered next).
This bonus can be used when there is a pent-up traffic demand to let more traffic flow through the switch using data sizes dictated by the burst size value.
- Burst size (KB): This is an often misunderstood value, so we’ll go into detail. The burst size is the actual amount of “burstable” data that is allowed to be transmitted at the peak bandwidth rate in kilobytes. Think of the burst bonus as a network traffic savings account. And the burst size is the maximum number of bytes that can go into that account. So, when you need to send more traffic than the average bandwidth value allows, you transmit a burst of traffic, which is more than the allowed average bandwidth. But this burst, which always stays at or below the allowable peak bandwidth, will be forced to end when the number of bytes in your traffic savings account, your burst bonus, reaches zero.
Figure 8.7 is an example showing a period of average traffic with a burst of peak bandwidth in the middle. You can determine how long the traffic will be able to burst by taking the burst size (KB) amount divided by the peak bandwidth (kbps).
Figure 8.7 A traffic-shaping graph showing average and peak bandwidth
Making changes to the traffic-shaping values will instantly begin enforcing the limitations on the switch—there is no restart or warm-up period.
Traffic Shaping Math
Here’s a concrete example showing how to calculate how long traffic will peak in a “best case” scenario:
- Let’s assume, for easy math, that you set the average bandwidth value to 1,000 Kbps.
- You also set the peak bandwidth to 2,000 Kbps, which is twice the value of the average bandwidth.
- Finally, you configure the burst size to 1,000 kilobytes (KB). Hint—don’t forget that there are 8 bits in a byte, which means that 1,000 KB is 8,000 Kb. Big “B” is for bytes and little “b” is for bits.
If the burst bonus is completely full, which would mean that it’s the full value of the burst size (8,000 Kb), then you could peak for 4 seconds:
8,000 Kb burst size / 2,000 Kbps peak bandwidth = 8 / 2 = 4 seconds