Forum Discussion

Marcel_Derksen_'s avatar
Marcel_Derksen_
Icon for Nimbostratus rankNimbostratus
Mar 20, 2007

Counting number of active transactions of http

Hi,

 

We want to count the number of current http transaction that is active on one of the pool members. Since we have only one pool with one member we made a simple irule to count the number.

 

The principle is that we increase a parameter with one every time the http event http_request is fired and decrease the same parameter every time the http_response is fired.

 

What we saw when we tested this is that not every http_request is followed by a http_response event. This results in a increasing number of active transactions and so giving us the wrong information.

 

We also included the event client_closed event to decrease the parameter with one but this also does not count correctly.

 

 

The irule:

 

when RULE_INIT {

 

set ::total_active_trans 0

 

set ::max_active_trans 0

 

set ::cur_active_trans 0

 

set ::trans 0

 

set ::number_response 0

 

}

 

 

when CLIENT_ACCEPTED {

 

set ::request_number 0

 

set ::number_response 0

 

set ::diff 0

 

}

 

 

when HTTP_REQUEST {

 

incr ::total_active_trans

 

incr ::cur_active_trans

 

incr ::trans

 

set ::request_number [HTTP::request_num]

 

if {$::cur_active_trans > $::max_active_trans} {

 

set ::max_active_trans $::cur_active_trans

 

}

 

if { $::trans == 1000 } {

 

log local0. "transactions (cur/max/tot): $::cur_active_trans/$::max_active_trans/$::total_active_trans"

 

set ::trans 0

 

}

 

}

 

 

when HTTP_RESPONSE {

 

incr ::cur_active_trans -1

 

incr ::number_response 1

 

}

 

 

when CLIENT_CLOSED {

 

if { $::number_response equals $::request_number } {

 

} else {

 

incr ::diff $::request_number

 

incr ::diff -$::number_response

 

incr ::cur_active_trans $::diff

 

}

 

log local0. "transactions2 (cur/max/tot): $::cur_active_trans/$::max_active_trans/$::total_active_trans"

 

}

 

 

Can anyone help to solve this? We want to limit the number of transactions that is send to a pool member.

 

 

Marcel.

1 Reply

  • Take a look at the following article

     

     

    http://devcentral.f5.com/Default.aspx?tabid=63&articleType=ArticleView&articleId=66