I feel this is quite complicated way of distributing the load. Have you tried the simple methods first and failed ? My recommendations are "Least Connections (Member)" for starters and then try the Predictive method. Utilize OneConnect if you want to load balance HTTP Requests instead of connections.
If you still insist on using datagroup, this is a rough iRule for starters:
when CLIENT_ACCEPTED {
if { [class search -value CLASS_DATAGROUP] eq "1" } {
set IP [class search CLASS_DATAGROUP]
node $IP 80
}
}
I would like to warn that using node in iRule can break certain persistence function and has caused trouble when upgrading between 10.x and 11.x code version.