Forum Discussion

Kevin_Davies_40's avatar
Jan 20, 2011

To INIT or not to INIT, that is the question.

When is the right time to use RULE_INIT and why would you use it given the following...



1. If you change anything in RULE_INIT you need to reload the box.


2. Globals are not CMP compatible and limit you to one cpu/core. On a 3900 thats %25 of the box.


3. Static globals don't change so why not just use local vars in the first iRule ~ same effect.


4. RULE_INIT has no access to data groups or tables


5. Session table (UIE) is ideal for CMP compatible global storage across the box.


6. Any globals in RULE_INIT are actually limited to the VIP in which the rule is attached?



I kind of get you need some place to set initial values, like how would you set the value the first time because you can't rely on connection events to do it for you. It is just that globals are not all that useful because of limitations and static globals, well if the value is not going to change you might as well just put a var statement in the first iRule in the chain. Same thing as far as I can see. Then on top of that, bringing down the box just to change an iRule just seems to be all kinds of wrong.



I wrote the following bit of code to load values for every connection from a data group. It could just as well be var statements for simpler requirements.





set myclass "initialize"


foreach item [class names ${myclass}] {


set [getfield $item " " 1] [getfield $item " " 2]







class initialize {




"foobar 2"


"foobear teddy"







Gives you foobar = "2", foobear = "teddy".



Kind Regards