Forum Discussion

Brian_Gibson_30's avatar
Brian_Gibson_30
Icon for Nimbostratus rankNimbostratus
Jun 25, 2014

Using an Irule to load balance between multiple pools

Does anyone know of a way to create an Irule to load balance connections between multiple pools?

 

I have a need to load balance between 4 pools of 2 servers each.

 

9 Replies

  • Since we're on the experimental track... Never tried this mind you, but perhaps worth a try?

     

    1. Create Pool 1: Members A/B
    2. Create Pool 2: Members C/D
    3. Create virtual server 1: Default pool Pool 1
    4. Create virtual server 2: Default pool Pool 2
    5. Create Pool 3 with VS1 and VS2 as members.
    6. Create a master VS using Pool 3.

    Does that make sense?

     

    /Patrik

     

  • So I was able to create the pool of VIPs. It looks good. But it doesn't seem to be passing traffic. I'm going to continue playing around with this and see if I can get it to work.

     

  • Read what you posted and read the article a bit closer:

    It is possible to add a local virtual server as a pool member to a BIG-IP standalone or redundant system. However, the BIG-IP does not respond to its own ARP requests for locally hosted virtual server addresses, and thus is unable to establish a network connection to a locally hosted virtual server. As a result, if you add a locally hosted virtual server to a BIG-IP load balancing pool, no traffic will ever be sent to that pool member, as it is not possible for the system to monitor or load balance traffic to that pool member.
    

    But it also states this:

    Beginning in BIG-IP 9.4, you can specify a local virtual server as a load balancing target for another virtual server by using the virtual iRule command. To direct traffic to the second virtual server, apply an iRule that uses logic similar to the following example to the first virtual server (the one that will accept client connections):
    
    when HTTP_REQUEST {
       if { [HTTP::uri] contains "param=x" } {
          virtual VS_2
       }
    }
    

    /Patrik

  • Ok, it ain't pretty, but what about something like this?

    when CLIENT_ACCEPTED {
    
        Returns 1 or 2 based on IP
        set poolselection [expr {[crc32 [IP::client_addr]] % 2 }]
    
        if { $poolselection eq 1 } {
            if { [active_members pool1] > 0 } {
                pool pool1
            } else {
                pool pool2
            }
        } else {
            if { [active_members pool2] > 0 } {
                pool pool2
            } else {
                pool pool1
            }
        }
    }
    

    /Patrik

  • Patrik,

     

    As you pointed out upthread, the pool of virtual servers didn't work.

     

    That is a pretty interesting way to create a sort of random number methodology. I will test it next week. I am on vacation this week. Thank you for the idea though!

     

    • Patrik_Jonsson's avatar
      Patrik_Jonsson
      Icon for MVP rankMVP
      No problem! Just curious to know if it worked, enjoy your vacation! /Patrik