CHAPTER 13 Optimizing fetching and caching The timeToIdleSeconds attribute defines the expiry time in seconds since an element was last accessed in the cache. You must set a sensible value here, because you don t want unused bids to consume memory. The timeToLiveSeconds attribute defines the maximum expiry time in seconds since the element was added to the cache. Because bids are immutable, you don t need them to be removed from the cache if they re being accessed regularly. Hence, timeToLive- Seconds is set to a high number. The result is that cached bids are removed from the cache if they haven t been used in the past 30 minutes or if they re the least recently used item when the total size of the cache has reached its maximum limit of 50,000 elements. You disable the disk-based cache in this example because you anticipate that the application server will be deployed to the same machine as the database. If the expected physical architecture was different, you might enable the disk-based cache to reduce network traffic. Accessing data on the local disk is faster than accessing the database across a network. Optimal cache eviction policies are, as you can see, specific to the data and application. You must consider many external factors, including available memory on the application server machine, expected load on the database machine, network latency, existence of legacy applications, and so on. Some of these factors can t be known at development time, so you often need to iteratively test the performance impact of different settings in the production environment or a simulation. We consider optimization with the second-level cache something you won t do during development, because testing without real datasets and concurrency doesn t show the final performance and scalability of the system. This is especially true in a more complex scenario, with a replicated cache in a cluster of machines. 13.4.4 Setting up a replicated cache EHCache is an excellent cache provider if your application is deployed on a single virtual machine. However, enterprise applications supporting thousands of concurrent users may require more computing power, and scaling your application may be critical to the success of your project. Hibernate applications are naturally
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.
This entry was posted
on Tuesday, March 18th, 2008 at 2:59 am and is filed under j2ee.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.