Monday, September 29, 2008

Memcached and Terracotta : Alternatives or Complementary ?

Last week I was having a chatty tweeter session with Ari Zilka, CTO of Terracotta. It all started with Ari's initial observation regarding the confusion that exists in people's mind regarding the actual use of memcached and how it compares to Terracotta as a caching solution. Ari was chatty and I thought it would be pretty useful to share his observations with a broader audience. Here is a transcript of the chat, with some snippets of my own personal observations and conclusions ..

Do you think Terracotta is an alternative to Memcached ?

The following is a snapshot directly captured from the Twitter stream ..



Reminder to self :

  • Memcached is a specialized engine for caching *only*. In case you are trying to use it as a data store, think twice and refactor your thoughts.

  • Memcached is NOT a distributed hash table. This is quite a popular misconception that even Dare also mentions in one of his recent posts. Every memcached server is atomic and is not aware of any other memcached server in the cluster. Any algorithm for distribution, HA, failover is the responsibility of the client.

  • How do you handle database updates and prevent staleness of your memcached data ? Updates to data are usually handled by pushing writes to the database and then having some asynchronous processes (or database triggers) build objects that are pushed into memcached. In case of Terracotta it is the other way round. You write into Terracotta Network Attached Memory and the data gets pushed into the database through asynchronous write behinds.

  • Terracotta offers a truly coherent and clustered cache that remains consistent even in the presence of database writes through write behind to System of Record. Hence by writing data directly into Terracotta Network Attached Memory, data can be safely and durable stored, without risk of loss or corruption, and later drained to the DB asynchronously.


Can we conclude that for read-only (mostly) usecases, use memcached, while, for read-write usecases, use Terracotta to obtain transparent durability to the persistent store. Rather than alternatives, the two technologies are complementary.

6 comments:

Unknown said...

That is the exact conclusion I would make.

Somehow the synopsis makes me sound much smarter. I like it!

Cheers,

--Ari

Dustin Ted Whitney said...

What's "HA"? hardware abstraction?

Anonymous said...

HA = High Availability

Anonymous said...

It is a distributed hashtable, where every node is a bucket in the table. It is the client's responsibility to hash to the correct node, as the nodes themselves are independant.

Another major difference is that memcached is an N server model, where failure is simply a performance issue. Terracotta is a central server model where failure is a production outage.

Anonymous said...

Outage would be possible with Terracotta only if it is not set up for HA (active passive servers).

Unknown said...

Anonymous: Terracotta is not a "central server". It is a server array. That array is both mirrored and striped so losing a server in Terracotta is neither a performance issue nor an outage. If one node goes down, its mirror transparently takes over.

Cheers,

--Ari