Forum Discussion
Hamdi_Fersi_350
Dec 10, 2015Nimbostratus
Round-Robin based on client IP
Hi,
Is there a way to make round-robin based on client source IP?
And what is the difference between source and destination persistence profile?
Thanks,
Dec 14, 2015
Hi Hamdi,
you may give the following code a try to start with:
when CLIENT_ACCEPTED {
set dynamic_member_list [active_members -list [LB::server pool]]
build table with client IP as key and request counter as value; increase per new connection
set member_pointer [table incr [IP::client_addr]]
log local0. "member_pointer <$member_pointer>"
if {$member_pointer >= [active_members [LB::server pool]]} {
initialize table entry if client has sent more requests than poolmembers exist
table set [IP::client_addr] 0
set member_pointer 0
log local0. "initialize member_pointer <$member_pointer>"
}
log local0. "pool [LB::server pool] member [lindex $dynamic_member_list $member_pointer]"
eval pool [LB::server pool] member [lindex $dynamic_member_list $member_pointer]
}
I tried to keep it as generic as possible. Alternatively you may make it faster using static lists of pool members.
Using tables may consume an unpredictable amount of memory and slow down the whole system as they are a shared resource. Thanks, Stephan
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