Forum Discussion

bfuller_9471's avatar
bfuller_9471
Icon for Nimbostratus rankNimbostratus
Apr 06, 2010

iRule - a better way?

Hi, during performance tests we are crushing the BigIP TMM cpu to the point where BigIP is lagged.

 

 

I've narrowed it down to the regsub's in this method which was written 5 years ago. Is there a better way of doing this?

 

 

 

when HTTP_RESPONSE_DATA {

 

set payload [HTTP::payload]

 

when payload is received, insert ID parameter into each URL

 

this expression inserts the ID into URIs with ? already

 

regsub -all {(/wps/.*?portal/ts/)([^>]+)(\?)([^<]+)(\"|\s)} $payload "\\1\\2\\3LBCID=$id\\&\\4\\5" payload

 

this expression inserts the ID into URIs without ?

 

regsub -all {(/wps/.*?portal/ts/)([^?]+)(\"|\s)} $payload "\\1\\2\?LBCID=$id\\3" payload

 

these expressions insert a hidden parameter containing $id into forms using the GET method

 

(browser is not submitting the URI parameter previously inserted)

 

Optimization options:

 

2nd regsub may be removed if all form actions can be modified to take the consistent order of <...method="get" action="/wps/...>

 

case sensitivity flag (?i) may also be removed if all form actions are consistent in case for the above string (All Caps in code and regsub recommended)

 

regsub -all {(?i)(method=\"get\" action=\"/wps/.*?portal/ts/.*?)(\\2" payload

 

regsub -all {(?i)(action=\"/wps/.*?portal/ts/.*?method=\"get\".*?)(\\2" payload

 

HTTP::payload replace 0 [HTTP::payload length] $payload

 

HTTP::release

 

}

 

}

4 Replies

  • Hi bfuller,

     

    Are you trying to rewrite response header information?

     

     

    Bhattman
  • No, we are trying to inject the lbcid variable into the html wherever links (href) or html forms are found.

     

  • Have you looked into a stream profile?

     

     

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

     

     

    Bhattman
  • As Bhattman suggests, using a stream profile should be more efficient. You'd want to use a STREAM::expression based iRule to configure the stream profile. The wiki page (STREAM::expression) has a few examples to get you started.

     

     

    Aaron