Distributed Caching via Memcached
Alan Harris · Apress eBooks · 2010
When working with large-scale applications that serve millions of requests a day (or more), even a well-written data-intensive application can begin to show cracks. These issues may appear in the form of slow responses, timeouts, or a complete loss of service until the incoming traffic is reduced. Besides disk I/O, one of the most costly tasks in your performance budget is the communication to and from your database. Although today’s relational database management systems (RDBMSs) are excellent at storing execution plans and retrieving data quickly, sometimes the sheer volume of requests and minor delays in handling them are overwhelming to one component or another along the processing pipeline. The obvious solution is to cache frequently used or infrequently changing data to avoid the trip to the database. It’s not a silver bullet, however. For applications that are deployed on multiple servers (for example, in a load-balanced environment), the in-session cache quickly becomes insufficient for reasons we will look at shortly. In this chapter, we’ll discuss the solution to that problem: the distributed cache. We’ll cover what it is, what it is not, and best practices for using it. We’ll also create a tree structure for our CMS and explore how a distributed cache is an ideal location for storing such objects; we’ll also learn why configuring Memcached properly is critical for effective cache usage.