posted 21 years ago
My exposure to the issue is limited, but I'll take a shot at it.
When you cluster you have to decide what you are clustering. You can have a cluster of web containers (servers) completely independent of the notion of having a cluster of ejb containers (servers). People want clusters for two reasons:
1. scaling performance to enable more requests to be processed, and
2. creating fault-tolerance in case a server goes down.
The second reason is the more problematic one from a performance standpoint. It means that if a user U made requests that were processed by server S1 before S1 failed, U's requests should be transparently handled by some server S2 when the cluster manager re-routes the requests to S2.
This is dead easy for stateless session beans, entity beans, and message-driven beans. It isn't easy for web sessions or stateful session beans. The reason? Every time the state changes, those changes must be broadcast across the cluster. Synchronizing big session state, no matter where it is located, can be a performance problem for clusters. The solution is to keep the amount of state information small.
In both approaches, stateful bean versus web session, you could do either a good or a bad job of minimizing session state, but container callbacks like ejbActivate/ejbPassivate are obvious opportunities for a developer to make some memory-mangement/performance tradeoff decisions.
One other point, performance related but not cluster related. Web session data can result in poor performance relative to stateful session beans for another reason. If you are caching data in a web session to feed back into future method calls on remote interfaces, that data has to be marshalled/demarshalled when the remote interface methods are invoked. A stateful session bean doesn't have to serialize data it passes to other beans, if those beans are accessed via local references.
Reid - SCJP2 (April 2002)