Forum Discussion

keith_varga_107's avatar
keith_varga_107
Icon for Nimbostratus rankNimbostratus
May 17, 2012

fixed HTTP page automatically when the # connections for the node is reached

DevCentral Team,

 

 

We have the following irule:

 

 

when HTTP_REQUEST {

 

HTTP::header insert "X_CLIENT_IP" [IP::client_addr]

 

HTTP::header insert "X-Forwarded-For" [IP::client_addr]

 

if { [string tolower [HTTP::uri]] contains "pmcserver" } {

 

pool pm3_qa_pmcserver

 

return

 

} elseif { [string tolower [HTTP::uri]] starts_with "/partner" } {

 

pool pm3_qa_soap

 

return

 

} else {

 

pool pm3_qa_web

 

return

 

}

 

}

 

 

 

Within the pm3_qa_pmcserver pool, we have two nodes that accept traffic, and have the pool set to least connections LB method. The developers would like to know of a way we can adjust our irule to do the following:

 

 

If traffic bound to the node residing in the pm3_qa_pmcserver pool surpasses the F5 connection limit that is set for that node, send the user to a fixed HTTP page automatically.

 

 

The mission is to not overwhelm the pmc server program on the backend if the F5 connection limit is already reached, and just let the F5 send the user to a url telling them the PMC program is 'too busy' instead.

 

 

thanks much, Keith Varga
  • George_Watkins_'s avatar
    George_Watkins_
    Historic F5 Account
    If the node limit is reached the LB_FAILED event will be triggered. This iRule should do the trick:

    when LB_FAILED { 
         HTTP::redirect "http://mysite.com/over-limit.html" 
     }

    -George
  • George,

     

     

    thanks a million!

     

     

    So, will putting the LB_FAILED when statement right after the pool selection work ok?

     

     

    when HTTP_REQUEST {

     

    HTTP::header insert "X_CLIENT_IP" [IP::client_addr]

     

    HTTP::header insert "X-Forwarded-For" [IP::client_addr]

     

    if { [string tolower [HTTP::uri]] contains "pmcserver" } {

     

    pool pm3_qa_pmcserver

     

    when LB_FAILED {

     

    HTTP::redirect "http://mysite.com/over-limit.html"

     

    return

     

    }

     

    return

     

    } elseif { [string tolower [HTTP::uri]] starts_with "/partner" } {

     

    pool pm3_qa_soap

     

    return

     

    } else {

     

    pool pm3_qa_web

     

    return

     

    }

     

    }

     

     

    Also, i was reading this article:

     

    https://devcentral.f5.com/Community/GroupDetails/tabid/1082223/asg/50/aft/15238/showtab/groupforums/Default.aspx

     

     

    and, inside it states this:

     

    LB_FAILED is triggered in a variety of circumstances. I'll list a few off the top of my head:

     

    a) no pool selected

     

    b) no available pool members in selected pool

     

    c) no route to pool member

     

    d) failed to connect to pool member With regard to

     

    d). The "max retrans syn" option in the TCP profile will affect the timeout.

     

     

    Looks like "Maximum Syn Retransmissions" is set to 4 in LTM's default tcp profile though, so LB_FAILED would be triggered if server didn't respond in 45 seconds:

     

     

    1st SYN: 0

     

    2nd SYN: +3 seconds

     

    3rd SYN: +6 seconds

     

    4th SYN: +12 seconds

     

    5th SYN: +24 seconds

     

    ====================== LB_FAILED: 45 seconds

     

     

    So, would that mean that the user would have to wait 45 seconds to be redirected to the http://mysite.com/over-limit.html URL? If so, is there any way to speed up this redirect if the node's connections are all used up?

     

     

     

    thanks much,

     

    Keith
  • George_Watkins_'s avatar
    George_Watkins_
    Historic F5 Account
    Keith,

    You cannot nest events in iRules: LB_FAILED cannot reside inside of HTTP_REQUEST. Your iRule will probably look something like this:

    when HTTP_REQUEST {  
         HTTP::header insert "X_CLIENT_IP" [IP::client_addr]  
         HTTP::header insert "X-Forwarded-For" [IP::client_addr]  
      
         if { [string tolower [HTTP::uri]] contains "pmcserver" } {  
             pool pm3_qa_pmcserver  
         } elseif { [string tolower [HTTP::uri]] starts_with "/partner" } {  
             pool pm3_qa_soap 
         } else {  
             pool pm3_qa_web 
         }  
     } 
     when LB_FAILED {  
         HTTP::redirect "http://mysite.com/over-limit.html"  
     }

    The LB_FAILED event will be triggered the instant that a new connection attempt is made to a pool whose connection limit has already been reached. There are a number of different circumstances that trigger LB_FAILED event and they all have different criteria for load balancing failure. Hope that helps,

    -George
  • George,

     

     

    Can't thank you enough for the help. You've answered all our questions.

     

     

    Thanks very much!

     

    -Keith