[jboss-user] [EJB 3.0] - Re: Stateless Session Beans - Static Variables - Concurrency
ColinEberhardt
do-not-reply at jboss.com
Fri Mar 16 12:24:44 EDT 2007
There are a couple of consequences to your method of caching data:
1. You certainly will hit concurrency issues. Your container will most likely hold a pool of SLSB instances, enabling it to service requests from a number of client. These request may result in concurrent access of your cache data.
2. This will certainly not work in a clustered environment. The different container instances will run under different JVMs. Static data is only shared between classes runnign in the same JVM.
SLSB are simply not designed to be used in this way. The JEE5 framework is designed in such a way that developers do not have to worry about the mechanics of concurrent accesses or clustering. You are breeaking this!
Are you sure that you need this cache which you have implemented? Have you executed performance tests and found that the system is slow?
Optimising for performance too early results in ver porr designs.
Are you aware fo the fact that Hibernate offers 3 levels of caching? I should imagine that your data will sit quite happily within the Hibernate L2 cache and that your database will not be repeatedly hit.
If you do test your system and find that the performance is poor, your first strtegy shoud be to try tuning teh system, not to hacjk together a cache!
Regards,
Colin E.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4028861#4028861
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4028861
More information about the jboss-user
mailing list