Forum Discussion

cbridges_128778's avatar
cbridges_128778
Icon for Nimbostratus rankNimbostratus
Jul 03, 2013

Balancing clients (persistent) based on header/request value?

Hi,

 

We have an F5 set up to balance clients between 4 Tomcat instances. When these clients send a request, they are pinned to a Tomcat instance, using a unique client thread id http header. This works fine.

 

However, our application has a need to be able to balance clients among the Tomcat instances, based on a common client id.

 

So, here is what we want to happen....

 

We pass in several HTTP headers, 2 of which could be used for persistence and balancing:

 

threadID– a unique client thread ID that is used for the server affinity / session persistence. It’s basically a UUID.

 

clientID– a non-unique ID which ultimately specifies a common client (which owns the threads above).

 

So for example, the pseudocode might look like this:

 

For a given request with threadID= T, and clientID = C

 

If there exists a session for threadID= T, route the request to that server. (no brainer, the thread is already pinned)

 

Else (everything below is synchronized if that's possible?),

 

Determine the number of existing sessions on each Tomcat server for the given clientID = C

 

Route the request to the Tomcat server with the least sessions for clientID = C.

 

Persist T (with C), so that persistence and balancing can function properly.

 

Looking at that, it would probably require some kind of synchronization (?), but that would only be in the case that a client session/thread is not already pinned (i.e. the “Else” part).

 

IS THIS POSSIBLE?

 

If so, how?

 

BTW, our current iRule looks like this. But that only takes care of balancing ALL clients across the Tomcats, but not balancing per-clientID.

 

when HTTP_REQUEST {

 

set SessionId [HTTP::header threadID]

 

if { $SessionId != "" } {

 

persist uie $SessionId 3600

 

}

 

}

 

Thanks.

 

1 Reply

  • If there exists a session for threadID= T, route the request to that server. (no brainer, the thread is already pinned)who initially generates a threadID? is it server?

     

     

    Determine the number of existing sessions on each Tomcat server for the given clientID = Chow to count number of existing sessions (i.e. when is session considered closed)?