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:
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: