Forum Discussion

Chris_Klomp_115's avatar
Chris_Klomp_115
Icon for Nimbostratus rankNimbostratus
Jul 25, 2013

Multiple iRules for one server

Still fairly new to iRule programming. :-)

 

 

If I have two iRules working on an HTTP Request.

 

Can I apply them both to the VS or do I need to merge them into one rule?

 

And if you can apply both, what rule will be processed first?

 

 

Thanks, Chris.

 

2 Replies

  • Jnon's avatar
    Jnon
    Icon for Nimbostratus rankNimbostratus
    You can leave it as one rule or multiple. The will both execute at the same time. For example If you have when http request in each I rule both of those events have to be executed during http request. You can add a priority if you want one to execute in specific order. Be careful of irules using the same variables or selecting default pool.
  • If I may add, iRules look like scripts but they're actually "compiled" when updated. This compilation optimizes the events and commands, as much as possible, for optimal runtime. Should you have multiple iRules applied to a VIP, they are effectively combined. If you have multiple iRules applied to a VIP that have the same events, those events are also combined. You would use the priority option in the event declaration to specify the order of commands within the single compiled event.

     

     

    As J states, with multiple iRules you should to be mindful of both the order of events and commands, and when variables are both created and used (ie. don't try to use a variable in one iRule that hasn't yet been created by another).