368 CHAPTER 14 SOLVING COMMON JAVA EE (Apache web server tutorial)
Tuesday, December 4th, 2007368 CHAPTER 14 SOLVING COMMON JAVA EE PERFORMANCE PROBLEMS this complication is that if you have 100 statements that you want to cache, but you have 50 database connections in your connection pool, then you need enough memory to hold 5,000 prepared statements. Through performance monitoring, determine how many unique SQL statements your application is running, and from those unique statements, consider how many of them are executed very frequently. Entity Bean and Stateful Session Bean Caches While stateless objects can be pooled, stateful objects like entity beans and stateful session beans need to be cached, because each bean instance is unique. When you need a stateful object, you need a specific instance of that object, and a generic instance will not suffice. As an analogy, consider that when you check out of a supermarket which cashier you use doesn t matter; any cashier will do. In this example, cashiers can be pooled, because your only requirement is a cashier, not Steve the cashier. But when you leave the supermarket, you want to bring your children with you; other peoples children will not suffice: you need your own. In this example, children need to be cached. The benefit to using a cache is that you can serve requests from memory rather than going across the network to load an object from a database. Figure 14-10 illustrates this benefit. Because caches hold stateful information, they need to be configured at a finite size. If they were able to grow without bound, then your entire database would eventually be in memory! The size of the cache and the number of unique, frequently accessed objects dictate the performance of the cache. Figure 14-10. The application requests an object from the cache that is in the cache, so a reference to that object is returned without making a network trip to the database.
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.