The invention is a method and apparatus for maintaining session affinity
within a server farm when requests sharing a session ID switch between
server groups or between server clones in a single server group. In
accordance with the invention, client requests include a list of clone
identification codes, each code uniquely identifying a clone within a
server group for handling the request. The clone identification code may
be appended to a session identification code. For each different server
that handles a request in a session, a new clone identification code is
appended without deleting or overwriting any previously appended clone
identification codes. When a request is received, the list of clone
identification codes associated with the request is parsed in a
predetermined order to search for the first clone identification code
that matches one of the clone identification codes of a server in the
appropriate server group. If a match is detected, the request is
dispatched to that clone. If no match is found, the request is dispatched
to a server clone in the server group using any reasonable Work Load
Management (WLM) mechanism and then the clone identification code of the
selected clone is added to the list.