Forum Discussion

dIone_24797's avatar
dIone_24797
Icon for Nimbostratus rankNimbostratus
Jul 31, 2013

Number of Executions IRule

Hello community,

 

 

We are using an IRule to throttle traffic from our client. We would think the number of requests per second on the VIP would equal the number of times the Irule gets executed per second, however we are seeing a decrepancies in these values. We are using Solarwinds to get the number of Executions per second and the number of Requests Per second. We have found that these values are not equal(however they do trend in the same direction). The number of executions is always lower then the number of requests by about 200.

 

 

Can anyone explain why these two values would differ? We would expect them to be exactly the same and I am concerned it is not executing for all requests.

 

 

Below is the IRule we are using to throttle. We are using ltmRuleEventStatTotalExecutions and ltmVirtualServStatTotRequests to compute the requestsper Second and Executions per second.

 

 

Thank you!

 

 

when RULE_INIT {

 

set static::win_size 1000

 

set static::qps_hwm 1800

 

set static::no_bid_file "/Common/RTB_no_bid_response"

 

set static::window_count 10

 

 

set static::debug 1

 

 

array set ::time_windows {}

 

set ::req_counter 0

 

set ::sample_rate 100

 

set ::last_time [clock clicks -milliseconds]

 

}

 

 

when HTTP_REQUEST {

 

set ::req_counter [incr ::req_counter]

 

 

if { $::req_counter == $static::win_size } {

 

set timestamp [clock clicks -milliseconds]

 

set difference [expr {$timestamp - $::last_time}]

 

set current_qps [expr {double($static::win_size) / double($difference)}]

 

 

if {[info exists ::time_windows($static::window_count)]} {

 

for {set i 0} {$i < $static::window_count} {incr i} {

 

set tmp [lindex [array get ::time_windows [expr {$i + 1}]] 1]

 

set ::time_windows($i) $tmp

 

}

 

set ::time_windows($static::window_count) $current_qps

 

} else {

 

set ::time_windows([array size ::time_windows]) $current_qps

 

}

 

 

set total 0

 

foreach index [array names ::time_windows] {

 

set total [expr {$total + $::time_windows($index)}]

 

}

 

 

set avg_qps [expr {double($total) / [array size ::time_windows]}]

 

set avg_qps [expr {$avg_qps * 1000}]

 

 

if { $avg_qps < $static::qps_hwm } {

 

set ::sample_rate 100

 

} else {

 

set ::sample_rate [expr {100 * [expr {double($static::qps_hwm) / double($avg_qps)}]}]

 

}

 

 

set ::req_counter 0

 

set ::last_time $timestamp

 

 

if { $static::debug == 1 } {

 

log -noname local0. "Current avg qps: ${avg_qps}"

 

log -noname local0. "Current sample rate: ${::sample_rate}"

 

}

 

}

 

 

set random_number [expr {rand() * 100}]

 

 

if { $random_number >= $::sample_rate } {

 

HTTP::respond 200 content [ifile get $static::no_bid_file] Cache-Control "no-cache,no-store,must-revalidate" Pragma "no-cache" Expires "Fri, 01 Jan 1990 00:00:00 GMT"

 

return

 

}

 

}

 

4 Replies

  • it seems equal here. i am testing in 10.2.4. what version are you running? you have reset stats, haven't you?

    [root@ve10:Active] config  b virtual bar list
    virtual bar {
       snat automap
       pool foo
       destination 172.28.19.252:80
       ip protocol 6
       rules myrule
       profiles {
          http {}
          tcp {}
       }
    }
    [root@ve10:Active] config  b rule myrule list
    rule myrule {
       when HTTP_REQUEST {
            log local0. ""
    }
    }
    
    [root@ve10:Active] config  snmpwalk -v 2c -c public localhost f5|grep ltmRuleEventStatTotalExecutions|grep myrule
    F5-BIGIP-LOCAL-MIB::ltmRuleEventStatTotalExecutions."myrule"."HTTP_REQUEST".500 = INTEGER: 2000
    
    [root@ve10:Active] config  snmpwalk -v 2c -c public localhost f5|grep ltmVirtualServStatTotRequests
    F5-BIGIP-LOCAL-MIB::ltmVirtualServStatTotRequests."bar" = Counter64: 2000
    
  • We are running 11.1.0 and I reset my stats. As you can see the requests are slightly higher then the Executions. Hrmmmm.... Anyone have any thoughts on why?

     

     

    [admin@f5ltm01:Active] ~ snmpget -v 2c -c public localhost SNMPv2-SMI::enterprises.3375.2.2.10.2.3.1.27.18.47.67.111.109.109.111.110.47.82.84.66.95.71.79.79.71.76.69

     

    F5-BIGIP-LOCAL-MIB::ltmVirtualServStatTotRequests."/Common/RTB_GOOGLE" = Counter64: 2535

     

    [admin@f5ltm01:Active] ~ snmpget -v 2c -c public localhost SNMPv2-SMI::enterprises.3375.2.2.8.3.3.1.6.29.47.67.111.109.109.111.110.47.82.84.66.95.81.80.83.95.84.104.114.111.116.116.108.101.95.118.51.46.49.12.72.84.84.80.95.82.69.81.85.69.83.84.500

     

    F5-BIGIP-LOCAL-MIB::ltmRuleEventStatTotalExecutions."/Common/RTB_QPS_Throttle_v3.1"."HTTP_REQUEST".500 = INTEGER: 1991

     

  • i think i know what happens. it seems HTTP::respond is not counted in ltmVirtualServStatTotRequests.

    e.g.

    [root@ve10:Active] config  b virtual bar list
    virtual bar {
       snat automap
       pool foo
       destination 172.28.19.252:80
       ip protocol 6
       rules myrule
       profiles {
          http {}
          tcp {}
       }
    }
    [root@ve10:Active] config  b rule myrule list
    rule myrule {
       when HTTP_REQUEST {
            HTTP::respond 200
    }
    }
    
     generating 100 requests
    
    [root@centos17 ~] ab -n 100 http://172.28.19.252/
    
     stats
    
    [root@ve10:Active] config  snmpwalk -v 2c -c public localhost f5|grep ltmRuleEventStatTotalExecutions|grep myrule
    F5-BIGIP-LOCAL-MIB::ltmRuleEventStatTotalExecutions."myrule"."HTTP_REQUEST".500 = INTEGER: 100
    
    [root@ve10:Active] config  snmpwalk -v 2c -c public localhost f5|grep ltmVirtualServStatTotRequests
    F5-BIGIP-LOCAL-MIB::ltmVirtualServStatTotRequests."bar" = Counter64: 0
    
  • We are running 11.1.0by the way, since you are running 11.x, you had better use static global variable and table command instead of global variable since global variable will demote cmp.

     

     

    v.10 - A new iRules Namespace by Colin Walker

     

    https://devcentral.f5.com/tech-tips/articles/v10-a-new-irules-namespace.Ufnlpm0-YdU

     

     

    v10.1 - The table Command - The Basics by Spark

     

    https://devcentral.f5.com/tech-tips/articles/v101-the-table-command-the-basics.Ufnlqm0-YdU