Forum Discussion

Sulabh_Srivasta's avatar
Mar 20, 2020

Connection limit on virtual server and message back to client

I am trying to set max connection limit and connection/sec on a virtual server, once the max connection limit is reached can LTM send message back to client that " it is over limit, please try after some time" or any schedule that try during this time window ?? Do we need to make any changes of back end servers in pool ?

Will appreciate your answers.

7 Replies

  • Hello,

    Any solution for this issue, I am looking for same.

    Thanks

    • boneyard's avatar
      boneyard
      Icon for MVP rankMVP

      There is no build in function for this, you will need to create something yourself.

       

      So how are your iRule skills? 

       

      I tested the iRule from Sulabh_Srivasta and it works for me. If I open several TCP connections then the next HTTP request is closed with the message "over_limit". So the principle of that works and you can expand on that.

      It does use global variables which have effects, you can look here to see alternatives: https://my.f5.com/manage/s/article/K13033

  • try below iRule. Else you can also try by using FALLBACK HOST in http profile. You can enter a URL/VS-IP here so if the VS connection limits are reached it'll redirect clients to the URL/IP. And bind one iRULE which will just give response to clients e.g. - Service is unavailable

     

     

     

    when RULE_INIT {

      

      set ::max_connections 500

      set ::html_content "Try After sometime"

      

    }

    when CLIENT_ACCEPTED {

       

      set over_limit 0

      

      if {$::active_connections >= $::max_connections } {

       set over_limit 1

      } 

    }

    when HTTP_REQUEST {

       

      if {$over_limit}{

        

       HTTP::respond 200 content $::html_content

        

      }

    }

     

     

    2. If you are using Fallback host option

     

    when HTTP_REQUEST {

     

    HTTP::respond 503 content "Service Temporarily Unavailable"

     

    }

    • Sulabh_Srivasta's avatar
      Sulabh_Srivasta
      Icon for Cirrus rankCirrus

      I used the first option with your given iRule but didn't work, then tried fallback option that didn't work either. I am stuck now.

  • For testing, I am using this iRule but it is not working :

     

    when RULE_INIT {

      set ::active_connections 0

      set ::max_connections 2

      set ::html_content "over_limit"

    }

    when CLIENT_ACCEPTED {

        set over_limit 0

        if {$::active_connections > $::max_connections } {

       set over_limit 1

      } else {

       incr ::active_connections 1

      }

    }

    when HTTP_REQUEST {

      if {$over_limit}{

        HTTP::respond 200 content $::html_content

        HTTP::close

      }

    }

    when CLIENT_CLOSED {

      incr ::active_connections -1

    }

  • Hello,

     

    Connection limit that you want to put on F5 is specific to Virtual Server, Pool or Node. Now in your case, you want to put it on VS. In this case, no need of making any changes on backend servers. With connection limit settings on VS, F5 will just limit incoming connections as per configuration done.

     

    Hope it helps!

     

    Mayur

    • Sulabh_Srivasta's avatar
      Sulabh_Srivasta
      Icon for Cirrus rankCirrus

      Mayur, thanks for reply. My question is "can LTM send a response to client - over limit, please try after some time " ??