views:

64

answers:

2

I have a JSP which shows data by many aggregation types. E.g. By market, by category, by server type, etc.. What I have is the data by publisher and time. Publisher is the most granular level of data in my case.

Now this data changes on every 1/2 an hour. The number of data per half an hour is almost 5K and anyone at a time looks data for 4 hours to 24 hours. In these cases when server is loaded the JSP load time increases rapidly. I tried to use and LRU cache with LinkedHashMap but that seems not the optimum solution as performance is still not good.

Any idea about which data structure to use would be appreciated.

+3  A: 

You could use a cache tool like Ehcache.

John Paulett
I think, I need to read a lot on this!
DKSRathore
+1 ehcache is a good fit for most caching scenarios, it's very flexible
skaffman
I still haven't used in my code. I am trying to push it.
DKSRathore
+1  A: 

Was performance, poor, or did you have a low hit rate? Sometimes maintaining a cache is harder than just querying your data directly. This is especially true with low hit rates.

If it takes you 10ms to serve a cache hit, and 50ms to serve a cache miss, plus 20ms to store the cache hit, then you are only gaining 20ms for each cache hit, so 200ms for 10 hits. This sounds GREAT, but when you add in expiration, and invalidation, not to mention cache invalidation, suddenly you are at a point where it takes at least 10 hits for every miss to have cache be useful.

Caching is great for flash mobs, but for ad-hoc tools, a lot of time it can waste as many resources as it gains.

Hit rate is too low due to frequent change of data. And performance hit is proportional to this.
DKSRathore