e-Zest members share technology ideas to foster digital transformation.

What is Memcached?

Written by Manojkumar Soni | Dec 31, 2014 3:48:57 PM

In the web world, every user prefers applications which are really fast. To make the web application faster and equipped to handle more users at the same time, you will need to cache the most used data and store it in such a way that minimal resources are necessary to deliver the data to the application or to the user. Most of the applications do not even update their content/products database every 15 minutes which shows that it is not necessary to query the db every time a visitor enters a page.

Memcached is a Free and open source, high-performance, distributed memory object caching system, generic in nature, but originally intended for use in speeding up dynamic web applications by improving database load. It is generic in nature but because it is a key value store it helps speed up dynamic web applications by alleviating database load. It’s a simple server with an interface to let you store things in memory.
It can run on the same machine as your web server but scalability comes from distributing instances across multiple servers. In the Memcached system, each item contains a key and end time, raw data and optional flags. When an item is demanded, Memcached verifies the expiration time to see if the item is still valid before returning it to the client. The cache can be flawlessly integrated with the application by confirming that the cache is updated at the equal time as the database.
By default, Memcached acts as the least recently Used cache plus ending timeouts. If Memcached server runs out of memory, it looks for expired objects or items that need to be replaced. If more memory is needed after completely replacing the expired items, Memcached replaces all objects that have not been requested for a certain length of time (the expiration timeout period or longer), keeping more newly requested information in Memcached memory.
Many organizations like LiveJournal, Bebo, Wikipedia, Flickr, Twitter, Craigslist, Yellowbot, Youtube, WordPress.com, and Mixi use this technology.
PROS AND CONS OF USING Memcached:

Memcached is a good choice in many apps or website because of the following reasons:

  • Memcached can reward for insufficient ACID properties and will never block.
  • It is cross-platform and Cross-DBMS.
  • Memcached can share memory allows multiple processes to share a single cache.
  • The instances of Memcached can be shared by many readers.
  • Memcached Cache requests can be distributed over multiple instances.
  • Memcached is often faster than reading from a database; mainly when content has been pre-filtered and pre-sorted, and is cached in a serialized object format (for example JSON) that can be quickly reconstructed by the application. Information read from db is commonly based on rows and columns, and these needs to be collected into objects which have a significant overhead cost if performed frequently.

Although, many have been able to optimize db performance through the use of Memcached it may not be the finest solution for every situation.

Memcached also has certain drawbacks:

  • Memcached Size Requirement.
  • It does not have much Documentation support.
  • Volatility (unfortunately if a Memcached server instance crashes, any object data stored within that session will be destroyed).
  • Security (In Memcached there is no authentication feature built in).