Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Developed by Danga Interactive to improve site performance on LiveJournal.com, Memcached's distributed architecture today supports the exponential scalability of social web applications like Twitter, Facebook, and Wikipedia. In this two-part tutorial, Sunil Patil introduces Memcached's distributed hashtable architecture and gets you started with using it to cache data for your own database-driven Java enterprise applications.
This tutorial introduces you to using Memcached to improve the performance of Java enterprise applications. The first half starts with an overview of traditional Java caching architectures as compared to Memcached's architecture. We'll also get Memcached installed on your machine and I'll introduce you to the setup and commands for working with Memcached via Telnet. In the second half we'll develop a "Hello Memcached" client program in Java, which we'll use to look under the hood of a spymemcached client. You'll also learn about using Memcached to reduce the load on your database server, and using it to cache dynamically generated page markup. Finally, we'll consider some advanced options for configuring spymemcached clients.
Java caching frameworks like EHCache and OSCache are essentially
HashMap objects in your application code. Whenever you add a new object to the cache it will be stored in the memory of your application.
This strategy works fine for storing small amounts of data, but it doesn't work for caching more than few gigabytes (GB).
The designers of the Memcached server took a distributed architectural approach, which allows for system scalability. As a
result, you can use Memcached to cache a huge amount of data.
The architecture of Memcached consists of two pieces. First is a Memcached server that runs in its own process. If you want to scale your application, you can install and run the Memcached server on additional machines. Instances of the Memcached server are not aware of each other. The Memcached client, the second piece of the Memcached system, does know about each of the servers. The client is responsible for picking up the server for each cache entry and either storing or getting the cache entry -- a process I'll discuss in detail later in the article.
If you have some experience working on Java EE web applications chances are that you've previously used an open source Java caching framework such as EHCache or OSCache. You might also have used a commercial caching framework that shipped as part of your application server, such as DynaCache (which ships with IBM WebSphere Application Server) or JBoss Cache (which ships with JBoss AS). Before we get into the hands-on learning part of this tutorial, it's important to understand how Memcached differs from these traditional Java caching frameworks.