Forum Discussion
how to use irule to achieve the complicated load balancing requirement (url contents, cookies for site stickiness)
The application is pointed to one vip with serveral url contents. These url contents are categorized to 2 classes (Content A and content B). Content A is load balanced in the pool-a (spanned at Site 1 and Site 2). Content B is load balanced in pool-b-site1 and pool-b-site2 based on its cookie A value (when accessing contentA, cookie A is insert for presistence). The client always accesses content A first. Then goes to content B.
The following is the load balancing logic we would like to achieve. Step 1, url content check. if it is content A, then go to pool-a (using cookie insert persistence, cookie name A). if it is content B, then go to step 2.
Step2, check the value of the cookie A to get the site stickiness. if cookie A's value is pointed to a site1 backend server, then go to pool-b-site1 (using cookie insert persistence, cookie name B) if cookie A's value is pointed to a site2 backend server, then go to pool-b-site2 (using cookie insert persistence, cookie name B)
Can I use irule to achieve that? I have never written irule before, any helpful information related above load balancing is appreciated.
Thanks in advance.
2 Replies
- David_Larsen_23Historic F5 AccountThis might get you started in the right direction. From here you will have to figure out how to set the persistence to follow the cookie value. That shouldn't be too hard: {{ when HTTP_REQUEST { switch -glob [string tolower [HTTP::path]] { "contenta" { pool A HTTP::header insert CookieA [LB::server] } "contentb" { set mycookie {[HTTP::cookie CookieA]} if [HTTP::cookie CookieA] { switch -glob $mycookie { "site1" { pool poolB-site1 HTTP::header insert CookieB [LB::server] HTTP::header remove CookieA } "site2" { pool poolB-site2 HTTP::header insert CookieB [LB::server] HTTP::header remove CookieA } } } } } } }}
- Deckard_214802
Nimbostratus
Did you try HTTP::cookie exists "value" command?
-==Deckard==-
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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