F5 is upgrading its customer support chat feature on My.F5.com. Chat support will be unavailable from 6am-10am PST on 1/20/26. Refer to K000159584 for details.

Forum Discussion

f5rocks_86658's avatar
f5rocks_86658
Icon for Nimbostratus rankNimbostratus
Sep 02, 2015

Load balancing of tcp data stream

We have one requirement of load balancing tcp data and not the tcp connection. It's GDS data for real time dynamic payment transactions. There could around 100 messages in 1 tcp connection. How to load balance these messages. Is mblb profile of any help. I read mbls is only used for sip, radius and diamter.

 

Kindlt guide for this situation

 

2 Replies

  • In my opinion you need to use an iRule to collect tcp payload and grab messages from the payload and route data based on your requirement.

    https://devcentral.f5.com/wiki/iRules.TCP.ashx.

    For example,

    when CLIENT_ACCEPTED {
      TCP::collect 15
    }
    when CLIENT_DATA {
      if { [TCP::payload 15] contains "XYZ" } {
         pool xyz_servers
      } else {
         pool web_servers
     }
     TCP::release
    }
    
  • An mblb profile can be used for cases beyond SIP, RADIUS, etc, and would be useful for your case. The generic profile can only be added from the cmdline: tmsh modify ltm virtual your-vserver profiles add { mblb { } }

    You can start by just using the CLIENT_ACCEPTED and CLIENT_DATA events. In CLIENT_ACCEPTED, you merely turn on TCP::collect. CLIENT_DATA is called each time a packet is received from the client. TCP::payload will contain all data received from the client that have not been released to a server. Within CLIENT_DATA, you must determine how big the first message is, release that message to a server (TCP::release ), then call TCP::notify eom to tell the LTM this was a complete message. TCP::payload now contains the rest of your messages (minus the first one you just released). As you continue to carve off and release messages from TCP::payload, the LTM will automatically be free to disperse these messages across the currently selected server pool because you have applied the mblb profile.

    when CLIENT_ACCEPTED { 
    log local0. 'conn recvd from [IP::client_addr]'
    TCP::collect
    }
    when CLIENT_DATA {
      log local0. 'got client data: [TCP::payload]'
      while { [regexp -indices '(.*?)'; [TCP::payload] transaction] } {
        log local0. 'A complete transaction was found between [lindex $transaction 0] and [lindex $transaction 1]'
        TCP::release [expr [lindex $transaction 1] + 1]
        TCP::notify eom
        log local0. 'Released a message to be routed by the LTM'
      }
      log local0. 'We ran out of client data or else the remaining data doesn't constitute a complete message. calling tcp collect'
      TCP::collect
    }