Forum Discussion
AppleBee_108607
Nov 02, 2010Historic F5 Account
CMP compatible strict Round Robin
Hi,
In addition to my another post, I have to urgently write an iRule to facilitate strict Round Robin event if the Virtual is CMPenabled.
I wrote code as follows but still have tw...
spark_86682
Nov 02, 2010Historic F5 Account
This rule is good, but the session table is a shared global structure, and this iRule does what's referred to as a "read-modify-write" to that data, which is bad. The three lines are:
set last_mod [table lookup -subtable tbl_rr_$static::poolname "last_mod"]
set new_mod [expr {[expr {$last_mod + 1}] % $num_pm}]
table set -subtable tbl_rr_$static::poolname "last_mod" $new_mod
The first one reads some data from the session table, the second one modifies that data, and the third one writes it back. Hence, "read-modify-write". Consider what would happen if two different connections came in at the same time and both executed this code. They would both read in a value (say, 3), both modify it (so new_mod would be 4), and both write it back out. So the two connections would both use the 4th pool member, which isn't what you want. In my other post, I use "table incr", which does an atomic increment, so this couldn't happen, since there's no read-modify-write happening. If two connections do an increment at the same time, one incrment command will actually be serviced first, so the "table incr" command will never return the same value to the two connections, so they'll always go to different pool members. Make sense?Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects