What is Memcached?


Memcached is a distributed memory caching system, which is used to boost the performance of database-powered websites by caching the requests and the responses between the user and the server. Put simply, anytime a particular page on such a website is opened, the script sends a query to its database to fetch the info that should be shown to the visitor. In case the latter clicks a link to go to another page, the whole procedure is repeated and this leads to plenty of database queries and excessive server load, particularly if the website has lots of simultaneous visitors. Memcached “remembers” this exchange of information, so in case any of these pages is opened again, the script no longer needs to cull any info from the database, as everything is provided by the caching platform. Thus, the overall speed of your website will “soar” and you will enjoy more pleased visitors and they will be able to browse your website faster. Besides, Memcached updates its cache if any info in the database is modified, so the website visitors will never see old data.

What Memcached Does

What Memcached Does?
What Memcached Does?

memcached allows you to take memory from parts of your system where you have more than you need and make it accessible to areas where you have less than you need.

memcached also allows you to make better use of your memory. If you consider the diagram to the right, you can see two deployment scenarios:

  1. Each node is completely independent (top).
  2. Each node can make use of memory from other nodes (bottom).

The first scenario illustrates the classic deployment strategy, however you’ll find that it’s both wasteful in the sense that the total cache size is a fraction of the actual capacity of your web farm, but also in the amount of effort required to keep the cache consistent across all of those nodes.

With memcached, you can see that all of the servers are looking into the same virtual pool of memory. This means that a given item is always stored and always retrieved from the same location in your entire web cluster.

Also, as the demand for your application grows to the point where you need to have more servers, it generally also grows in terms of the data that must be regularly accessed. A deployment strategy where these two aspects of your system scale together just makes sense.

The illustration to the right only shows two web servers for simplicity, but the property remains the same as the number increases. If you had fifty web servers, you’d still have a usable cache size of 64MB in the first example, but in the second, you’d have 3.2GB of usable cache.

Of course, you aren’t required to use your web server’s memory for cache. Many memcached users have dedicated machines that are built to only be memcached servers.

Intro to Memcached

Memcached – a Distributed Memory Object Caching System

Memcached was originally developed by Brad Fitzpatrick for LiveJournal in 2003.

Official website: Memcached.org

Leave a Reply

Your email address will not be published.Email address is required.