Forum Discussion
Kai_Wilke
Aug 24, 2017MVP
Hi swjo,
to overwrite the HTTP::host value based on the currently selected pool member (aka. just for pool member X.X.X.119), you have to use the
HTTP_REQUEST_SEND
event (triggered after pool member selection), filter on the selected pool member IP and finaly change the HTTP::host value to a random value based on a mod(rand())^4 calculation followed by an array lookup to retrive the HTTP::host names...
when RULE_INIT {
array set static::apisky {
"0" "api31sky.whypaymore.co.kr"
"1" "api32sky.whypaymore.co.kr"
"2" "api33sky.whypaymore.co.kr"
"3" "api34sky.whypaymore.co.kr"
}
}
when HTTP_REQUEST_SEND {
if { [LB::server addr] equals "X.X.X.119" } then {
clientside {
HTTP::host $static::apisky([expr { int( rand() * 100 ) % 4 }])
}
}
}
Note: The selection of the individual HTTP::host values in the example above is not a true "Round-Robin-Selection". Instead its more or less just a "Random-Selection". To implement a true "Round-Robin-Selection" you have to store a shared counter value into LTMs session-
so that each TMM core can access and also increase/rollover this information as needed. But in 9 out of 10 times a real "Round-Robin-Selection" isn't required and should therefor be avoided to save CPU cycles...[table]
Cheers, Kai