Forum Discussion

Ashish1982k_242's avatar
Ashish1982k_242
Icon for Altostratus rankAltostratus
May 31, 2018

iRule for cookie based load balancing

I am trying to create an iRule to load balance on cookie data. cookie Name- gcbSessionServer   I am using below code but it is giving error   May 31 11:10:20 ttncltmxza-p err tmm[17866]: 0122...
  • Ashish1982k_242's avatar
    Jun 02, 2018

    I am using below iRule and it works. I have single servers in pool and if the server is down LTM was throwing error.

     

    when HTTP_REQUEST {

     

    if { ([HTTP::cookie exists gcbSessionServer]) } {

     

    if { ([HTTP::cookie value "gcbSessionServer"] contains ".Co-browse_TENCBSD0_Node1") and ([active_members cct-cobrowse-ct-node-1_pool] > 0)} {

     

    pool cct-cobrowse-ct-node-1_pool

     

    log local0. " COOKIE->[HTTP::cookie value "gcbSessionServer"] Selected pool [LB::select] " }

     

    elseif { ([HTTP::cookie value "gcbSessionServer"] contains ".Co-browse_TENCBSD1_Node2") and ([active_members cct-cobrowse-ct-node-2_pool] > 0)} {

     

    pool cct-cobrowse-ct-node-2_pool

     

    log local0. " COOKIE->[HTTP::cookie value "gcbSessionServer"] Selected pool [LB::select] " }

     

    elseif { ([HTTP::cookie value "gcbSessionServer"] contains ".Co-browse_TENCBSD2_Node3") and ([active_members cct-cobrowse-ct-node-3_pool] > 0)} {

     

    pool cct-cobrowse-ct-node-3_pool

     

    log local0. " COOKIE->[HTTP::cookie value "gcbSessionServer"] Selected pool [LB::select] " }

     

    else {

     

    LB::mode rr

     

    pool /Common/cct-cobrowse-ct.app/cct-cobrowse-ct_pool

     

    log local0. " COOKIE FOUND Selected pool [LB::select] "

     

    } }

     

    else {

     

    LB::mode rr

     

    pool /Common/cct-cobrowse-ct.app/cct-cobrowse-ct_pool

     

    log local0. " NO COOKIE Selected pool [LB::select] "

     

    } }