Forum Discussion

NaThanSky's avatar
NaThanSky
Icon for Altostratus rankAltostratus
Feb 17, 2025

Implementing multi-link bandwidth usage threshold redundancy for outbound traffic

I have multiple link exports, using irules for outbound traffic. For example, there are currently China Telecom and China Unicom. Can I define the bandwidth usage of each link as 80% according to the policy or specify a threshold to implement a switching mechanism?

It cannot be set globally, only for member or outbound VS, or are there any permissions that can achieve it?

When the bandwidth usage of any member exceeds the custom value, traffic will no longer be allocated to the member, and the existing traffic sessions will remain unchanged and wait for aging.

 Thank you very much for discussing with each other!

  • f51's avatar
    f51
    Icon for Cumulonimbus rankCumulonimbus

    It sounds like you're managing bandwidth allocation across multiple links and want to ensure that traffic is distributed efficiently without overloading any single link. Based on what you've described, you want to implement a threshold mechanism to switch traffic allocation when bandwidth usage exceeds a certain percentage.

    Here are some key points to consider and possible solutions:

    iRules and Bandwidth Monitoring: iRules in F5 BIG-IP can be used for various traffic management tasks, but they are typically more suited for layer 7 (HTTP) manipulation rather than real-time bandwidth monitoring and control. If you need to monitor bandwidth usage dynamically, you might need to use other BIG-IP features or external monitoring tools.

    Rate Limiting and QoS: You might be able to use Rate Shaping or Quality of Service (QoS) features available in BIG-IP to define policies for bandwidth usage on a per-link basis. These features allow you to set maximum bandwidth limits and prioritize traffic, which could help in ensuring that no single link is overburdened.

    Here’s a high-level approach to achieve your goal:

    Monitor Bandwidth Utilization: Use SNMP or other monitoring tools to keep track of the bandwidth usage on each link.

    Trigger Actions Based on Thresholds: When the bandwidth usage of a link exceeds 80%, trigger a script or an API call to adjust the load balancing configuration.

    Adjust Traffic Distribution: Use the BIG-IP API or iControl LX to update the load balancing policies, ensuring traffic is redirected away from the overburdened link.

    Maintain Existing Sessions: Configure the load balancer to maintain existing sessions on the current link until they naturally expire or complete, while new sessions are directed to other links.

    Try below iRule and modify as you need.

    when CLIENT_ACCEPTED {
        # Define variables for the different links
        set china_telecom_pool "china_telecom_pool"
        set china_unicom_pool "china_unicom_pool"
        
        # Example condition: Redirect traffic based on a hypothetical variable
        if { [class match [IP::client_addr] equals china_telecom_clients] } {
            # Check if China Telecom bandwidth usage is below the threshold
            if { [active_members $china_telecom_pool] > 0 } {
                pool $china_telecom_pool
            } else {
                # Fallback to China Unicom if China Telecom is over the threshold
                pool $china_unicom_pool
            }
        } else {
            # Default to China Unicom for other traffic
            pool $china_unicom_pool
        }
    }

    when LB_FAILED {
        # Handle load balancing failures
        # Redirect traffic to the other pool if the selected pool is unavailable
        if { [LB::server pool] eq "china_telecom_pool" } {
            pool $china_unicom_pool
        } elseif { [LB::server pool] eq "china_unicom_pool" } {
            pool $china_telecom_pool
        }
    }

     

    • NaThanSky's avatar
      NaThanSky
      Icon for Altostratus rankAltostratus

      Your answer looks very similar to ai's reply. It seems unrealistic. SNMP external call monitoring is a very cumbersome task. I hope that it is feasible to control the link load through BWC. When the bandwidth of the specified member exceeds the threshold, it will no longer share new traffic.

    • NaThanSky's avatar
      NaThanSky
      Icon for Altostratus rankAltostratus

      when CLIENT_ACCEPTED {
          set mycookie "[IP::remote_addr]:[TCP::remote_port]"
       
          BWC::policy attach BandwidthControl_100Mbps $mycookie
          BWC::measure start session
          after 5 {
              set rate [BWC::measure get rate session]
              set bytes [BWC::measure get bytes session]
              log local0. "Rate: $rate/sec, Bytes: $bytes for [IP::remote_addr]:[TCP::remote_port]"
          }
          pool ChinaRadioTelevisionPool
      }

      Feb 24 16:36:34 F5-BIGIP-0C-13 info tmm4[18286]: Rule /Common/OutboundIRules <CLIENT_ACCEPTED>: Rate: 0/sec, Bytes: 0 for 172.16.0.30:43217
      Feb 24 16:36:34 F5-BIGIP-0C-13 info tmm6[18286]: Rule /Common/OutboundIRules <CLIENT_ACCEPTED>: Rate: 0/sec, Bytes: 0 for 172.16.0.30:42912

      The above irules seem like a good idea, but I don't know how to modify them to implement it.

      I am trying the link control permission module, but it does not provide a smooth switching solution. I need to specify a link. If the bandwidth exceeds the specified threshold of 100Mbps, but other specified address libraries still do not need to switch link exits, the remaining unspecified exits can be switched. How to set it through BWC policy? I have not found a way