StatelessVsStateful

Discussions

Performance and scalability: StatelessVsStateful

  1. StatelessVsStateful (2 messages)

    Most of us believe or hear statful session beans are resource hungry.

    Can you guys help me in differentiating statefulVsStateful in terms of performance and resources...

    Threaded Messages (2)

  2. StatelessVsStateful[ Go to top ]

    Number of Stateful Session EJB = Number of Clients

    Number of Stateless Session EJB < Number of Clients (typically much less)

    This is because Stateless Session EJB are pooled and can be shared by clients, while Stateful Session EJB cannot be pooled.
  3. StatelessVsStateful[ Go to top ]

    Well, obviously the most direct effect of SFSBs is that they require an active instance per client. With SLSBs the number of instances you need is generally the number of concurrent requests that may be made to the SLSB. This number is usually much smaller than the number of clients. If each session bean holds some expensive resources, the decrease in the number of instances can make a big performance improvement.

    Stateful beans also require more resources in terms of the work done by the container. For example, some containers will replicate stateful bean instances to provide error recovery. The stubs of stateful beans have to be smarter and know where in a cluster the live instance currently resides.

    Generally speaking stateless components scale better and are easier to cluster and provide failover for. If you can do without holding client-specific state on the server, that's probably the way to go. If you must have server-side state then SFSBs provide a reasonable solution.

    Gal