Fernando_Martín
Apr 01, 2010Nimbostratus
Optimize iRule for ASM
Dear all,
recently we are designed and activated an iRule to make several decisions:
- when there isn't any member available in the production pool, the request is redirected to a sorry;
- in other case the request is redirected to ASM.
This second case is a little special because the web app is written using two diferent charsets, win-1252 and utf-8, that are used depending of the first level of uri path. For example:
- utf-8: http://server/PATH1/piemf.txt or http://server/PATH2/qwxsa.txt
- win-1252: anypath else
We are developed an iRule to do this:
__> SORRY_POOL
______ _______ /
USER --->| vs |-->|iRule| --->HTTPClass_PROD_POOL_PATH1_PATH2-----> PROD_POOL
------ ------- \__>HTTPClass_PROD_POOL_PATH1_PATH2__/
\_>HTTPClass_PROD_POOL_REST________/
And this is the code:
when HTTP_REQUEST {
set debug "0"
if { [active_members PROD_POOL] < 1 } {
Pool selected in case of all production members are down
if { $debug } { log local0. "select Sorry" }
ASM must not work
HTTP::class disable
PoolSorry becomes traffic
pool SORRY_POOL
} else {
The variable gets the first level of path
set URI_value [findstr [HTTP::uri] "/" 1 "/"]
if { $debug } { log local0. "uri $URI_value" }
switch $URI_value {
PATH1 {
if { $debug } { log local0. "PATH1" }
HTTP::class enable
HTTP::class select HTTPClass_PROD_POOL_PATH1_PATH2
}
PATH2 {
if { $debug } { log local0. "PATH2" }
HTTP::class enable
HTTP::class select HTTPClass_PROD_POOL_PATH1_PATH2
}
default {
if { $debug } { log local0. "REST" }
HTTP::class enable
HTTP::class select HTTPClass_PROD_POOL_REST
}
}
}
}
This rule is applied in several VS.
Now all this configuration is applied and it works, but the performance of CPUs is very high (CPU0: 80%, CPU1: 100%, AVERAGE: 90%). The main overhead is being introduced by ASM (we can see in ASM CPU Graphs), but it is only a 40 % of CPU0.
We haven't an exact value of CPU impact of this iRule, but we think that it could be optimized to reduce the resouces needed.
Does someone how could we do better the iRule to reduce CPU utilization??
Regards,
fermarloe