Forum Discussion

Andy_park_66466's avatar
Andy_park_66466
Icon for Nimbostratus rankNimbostratus
Mar 21, 2006

Want http request limit !!

I had seen this subject → http://devcentral.f5.com/Default.aspx?tabid=28&view=topic&forumid=5&postid=2169

 

 

Where is " variable 'reqs_sec " ?

 

 

I think 'variable 'reqs_sec' is missing.

 

How can I get " request per sec " ?

 

  • when HTTP_REQUEST {

     

    set cur_time [clock seconds]

     

    if { [HTTP::request_num] > 1 } {

     

    if { $cur_time == $start_time } {

     

    if { $reqs_sec > 3 } {

     

    HTTP::respond 503 Retry-After 2

     

    }

     

    incr reqs_sec

     

    return

     

    }

     

    }

     

    set start_time $cur_time

     

    set reqs_sec 0

     

    }
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    In the example you've posted, taken from Unruley's posting in the thread mentioned, the reqs_sec variable is a variable that he's setting with the incr command. That command will increase the value of recs_sec by 1, and if the varible doesn't exist, it will initialize it and set it equal to 1.

     

     

    You can read more about the incr command in the TCL docs, here: Click here

     

     

    -Colin
  • When I use this iRule, I can see error message.

     

     

    when HTTP_REQUEST {

     

    set cur_time [clock seconds]

     

    if { [HTTP::request_num] > 1 } {

     

    if { $cur_time == $start_time } {

     

    if { $reqs_sec > 3 } {

     

    HTTP::respond 503

     

    Retry-After 120

     

    }

     

    incr reqs_sec

     

    return

     

    }

     

    }

     

    set start_time $cur_time

     

    set reqs_sec 0

     

    }

     

    ======================================

     

    I don`t know what the error message is.

     

     

    Apr 24 21:22:07 tmm tmm[726]: 01220001:3: TCL error: Rule test - while executing "HTTP::respond 503 "

     

    Apr 24 21:22:08 tmm tmm[726]: 01220001:3: TCL error: Rule test - while executing "HTTP::respond 503 "

     

    Apr 24 21:22:09 tmm tmm[726]: 01220001:3: TCL error: Rule test - while executing "HTTP::respond 503
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    The error is stating that the HTTP::respond 503 command is not executing properly. Have you tried the HTTP::respond syntax from the above rule, or perhaps responding with different HTTP codes to see if that may solve the problem?

     

     

    Colin
  • I already tried the HTTP::respond syntax from the above rule.

     

    But it is same problems.

     

     

    Apr 24 21:22:09 tmm tmm[726]: 01220001:3: TCL error: Rule test - while executing "HTTP::respond 503 Retry-After 2

     

     

    I need HTTP::respond 503 error message.

     

    Please help us.
  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    I've also run into an issue with 503 - seems it's not supported, or perhaps it needs a RetryAfter param. Didn't get a chance to check it out further, as 501 works just as well for our application and doesn't generate an error.

     

     

    I'll also be posting a nice request rate limiting iRule to the codeshare later today or tomorrow... stay tuned.

     

     

    /deb