Friday, April 10, 2009

FragmentCache part duex: Cleaning

I realized that I forgot to address an additional, critical, issue with fragment caching: cleaning out expired fragments.  A fragment cache implemented as I described in my last post would update expired fragments when requested, but what about expired fragments that aren't requested?  

If you externalized the cache itself, then your cache will likely support LRU or LFU expiration policies. But, if you're using a in-memory cache in the Java heap space, well, that's a memory leak.  If you cache a lot of fragments, failing to clean the cache is a recipe for maxing out the old generation space and thus causing Full GC's to run back-to-back, collecting just enough space to limp along, but not do any good, until eventually your application becomes non-responsive.  So, an additional requirement for an in-memory fragment cache is that you monitor the usage and have a cleaner task which runs, say, once an hour, to remove fragments that have expired and are not currently locked for update.  Doing this efficiently with a large cache requires using a data structure that supports thread-safe concurrent access, so as to avoid locking the whole cache while cleaning and maintain high throughput.  

6 comments:

alvine123 said...

Took a lot of time to read but I really found this very interesting and informative, thank you buddy for sharing.

SEO Company

SEO Services

SEM Services

alvine123 said...

I think we need to bring more ideas for this purpose. Involvement of young people can be handy in this regard. I am happy to find a good post here. Thank you

Social Media Marketing Services

Pay Per Click Services

Link Building Services

Content Writing Services

alvine123 said...

Very informative post. Keep up the good work. I would really look forward to your other posts

Logo Design

Cheap Logo Design

Affordable Logo Design

alvine123 said...

Thanks for your marvelous posting! I quite enjoyed reading it, you are a great author.I will be sure to bookmark your blog and definitely will come back from now on. I want to encourage that you continue your great job, have a nice day!

Logo Design Contests

Cheap Logo Design

Essay Help

Buy Essay

alvine123 said...

Nice and very helpful information i have got from your post. Even your whole blog is full of interesting information which is the great sign of a great blogger.

Cheap Custom Essays

Help With Essay

Write My Essay

Dissertation Help

domain hosting india said...

This is generally a wonderful website i should say,I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work