Memcached

When a high-performance distributed in-memory caching system is required, Memcached is the answer. Commonly used in web applications to deliver fast performance for storing simple datasets and relieving the database of commonly returned responses, Memcached works as a distributed cluster so the data being stored on the nodes is redundant and can be delivered to multiple nodes or multiple threads within our application at the same time.

One use case for Memcached is storing user sessions. Say we have an application that handles sessions within the application. Now, that works fine on one server as the application is receiving all the traffic and handling it on its own. Now, scaling this application is going to be difficult since, if we slice it up into a cluster, each node is going to only be aware of its own sessions. Once a node dies and the load balancer redirects the user sessions to another node, all the user session information will be lost.

So instead of having stateful nodes, we should be introducing an external data store to handle sessions. One way to do this is to set up a Memcached cluster and direct all our nodes to write the sessions to Memcached instead. It is multi threaded so all the nodes can read and write at the same time, and it uses a simple connection and data model so very little needs to be done to redesign our applications to use Memcached. 

Another really good scenario is when we require a high-performance cluster to store common responses from our database. Like in the example when we were calling the database thousands, possibly millions, of times to get the leader, we can set up a small Memcached cluster and store those responses from the first node that reads the database. All the consequent reads can be directed to the cache and thus our database load decreases dramatically.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.123.189