Sunday, August 12, 2007

Caching: Memcached and Terracotta

Applications are generally built with an expected user base but soon might be overwhelmed due to business demand. This is especially particularly true in the context of consumer facing applications. Caching is one of the most important aspect to improve application performance by storing object in Cache (memory) reducing database load.

Caching in a clustered environment requires a Distributed Caching solution which can support failover scenarios and data reliability. In this post I would like to explore the capabilities of Memcached and Terracotta as distributed caching solutions.

Memcached is a high-performance distributed object caching system with client APIs for Perl, PHP, Python, Ruby and Java. Here are some of its capabilities and limitations (using Java client API):

  • Requires objects to be Serializable
  • Object Identity is NOT preserved
  • Supports cache expiration
  • Does NOT handle failover scenarios
  • For a given object selects a server from a pool of cache server based on hash of the key
  • Easy to configure (through SockIOPool class)

Terracotta is an open-source Java based clustering solution for JVM. Distributed Caching can be achieved using Terracotta by using a java.util.HashMap or open-source caching solutions like EHCache, OSCache and JBoss TreeCache.

  • Preserves Object identity
  • Manages memory efficiently through Virtual Heap
  • Declarative requirement for lock support
  • Simple configuration file with Eclipse Tool support
  • Good documentation, support and active development
  • Due to the nature of its implementation certain classes are not Portable and hence cannot be used
  • Hard to determine which third-party classes are portable
  • Does NOT require classes to be serializable
  • Easy to configure and get started!
Technorati tags: ,


anjan bacchu said...

Hi There,

nice post.

It would be more helpful to your readers if you can create a feature comparison Table listing both Terracotta and Memcached.

Thank you,


Venkk Sastry said...

Hi Anjan

Its a good idea. I will try and post one in a table.


Hank Li said...

Your opinion is interesting. I did some research on this topic and post to my blog too.

Would like to know your opinion.

qnaguru said...

But are these really used in Production environments or they are only technology demostrators.

I know that FaceBook uses MemCache... do u know of anyone who uses Terracota in production.

Also, isn't Terracota a Tomcat-only solution?

Anonymous said...

Terracotta supports several platforms through modules (TIMs) that can be found on their website.

Pierce said...

viagra online
buy viagra
generic viagra

Disqus for techtalk