Forum Discussion

kevin_49292's avatar
kevin_49292
Icon for Nimbostratus rankNimbostratus
May 02, 2014

irule: load balance connections for diff pools

Hi

 

I have a situation were I need to send 50% of traffic to one pool & the rest 50% traffic to a diff pool ( i.e, 1st conn - pool A, 2nd conn pool B 3rd pool A 4th pool B.....) 2) is if the Pool A goes down then it should replace with Pool C & sme with pool B (if pool b goes down it should redirect to pool D)

 

when CLIENT_ACCEPTED { if { (rand() = .50 } { if { [active_members POOL-A] > 0 } { pool POOL-A } else { pool POOL-C } } else { if { [active_members POOL-B] > 0 } { pool POOL-B } else { pool POOL-D } } }

 

Let me know if this works, or if theres any better way to do this?

 

Thanks!

 

4 Replies

  • I suppose semantically speaking the following would work:

    when CLIENT_ACCEPTED {
        switch [expr {int(rand()*2)}] {
            0 { 
                if { [active_members POOL-A] > 0 } { 
                    pool POOL-A
                } else { 
                    pool POOL-C
                }
            }
            1 {
                if { [active_members POOL-B] > 0 } { 
                    pool POOL-B
                } else { 
                    pool POOL-D
                } 
            }
        }       
    }
    

    But of course this doesn't deal with any sort of persistence, and certainly would break any persistence method applied to the VIP without some additional logic. Given that you want to basically spread the load across all of the members of pools A and B and only use pools C and D if either of the other two fail, what about putting all of the servers into a single pool, and then setting A and B members to a higher priority activation group. This would evenly distribute the load across A and B members and only use C an D members if some priority activation threshold was met.

  • Thanks Kevin! We thought of doing priority activation, but POOL A & B are clustered env, so we can't add the servers in one POOL & use the priority activation in this stiuation.

     

  • HI Kevin, thanks for the irule(it worked perfectly for us)

     

    we are looking to add one more logic to the above irule. ie, Active connections for POOL A + POOL C = POOL B + POOL D( more or less equal to) I am not sure how to proceed with this, any info would help.

     

    Thanks!

     

  • we are looking to add one more logic to the above irule. ie, Active connections for POOL A + POOL C = POOL B + POOL D( more or less equal to)

     

    you may be able to track active connection using irule but i think it is better to use built-in load balancing algorithm. anyway, as you may know, it is independent in each tmm instance.

     

    sol6406: Overview of Least Connections, Fastest, Observed, and Predictive load balancing modes

     

    http://support.f5.com/kb/en-us/solutions/public/6000/400/sol6406.html

     

    sol14358: Overview of Clustered Multiprocessing (11.3.0 and later)

     

    http://support.f5.com/kb/en-us/solutions/public/14000/300/sol14358.html

     

    just my 2 cents.