Where should that be done?
Posted by Richard Mon, Sep 26 2005 22:14
I help maintain a fairly large Java application written using EJBs. At the time it was written, we using some of the latest techniques for cache information on the application server itself. This has really proven useful and has decreased the load on the database server. During peak loads, this has proven beneficial and even necessary.
So, has this caching had any negative side affects?
Probably. I think it has made us forget some of the basics of database tuning. For example, we have a certain routine that loads a number of cached beans. The first time you call this routine, it takes a while to load the beans, but once they are cached it is very fast. The initial load has slowed over time, but we (as developers relying on caching) assumed it was the growth in the data - without looking at the details too much. We had added several calls to the initialization of the bean (probably over a year ago). One of these calls was to a table that has grown over time. It turns out with the addition of a database index load times were cut in half.
Back to my question. Where should that (caching of data) be done? Database servers are continuing to get faster and smarter about data retrieval. They can be clustered and tuned for very specific functions. Most of them provide some level of caching by default. If we are caching at the application server and database, it seems a little redundant and increases complexity. It also gives the developers a crutch a stand on - as seen in the example above, we assumed it was OK to load slowly the first time. If all data and caching was maintained in the database, this might decrease the complexity of the application and allow the DBAs to focus on things they are good at (instead of us having to explain how an application server works).
This sounds very similar to what some other frameworks are calling: Share-Nothing Architecture.
Is this application ready for a major shift like this? I don't know. Do we have applications that are good candidates for this? Most likely. To be fair, the complexity in setting up cached environments in Java has become increasingly easier to do. Maybe there is more to evaluate than simply caching, but I will leave that for another time.
