Chapter 7: Static Meets Dynamic Adding Caches to Reduce Costs
This chapter excerpt is from "Scalable Internet Architectures", by Theo Schlossnagle, Copyright 2007 by Sams Publishing, ISBN 067232699x. Reprinted with permission, all rights reserved. To review a complete Table of Contents, please visit: www.samspublishing.com/title/067232699x
Chapter 6, "Static Content Serving for Speed and Glory," walked you through building a high-capacity static content serving system using a web caching system as the core technology. That software was responsible for fetching static content from "master" servers and peddling the cached content efficiently and inexpensively.
Why is the problem so different when the content is no longer static? Why can't we use the exact same solution presented in Chapter 6 for dynamic content?
Think of a website as if it were a phone book. A cache is a piece of paper that sits next to your phone book on which you record all the numbers you look up. Sounds like a good idea, right? So much so that you will probably tape that piece of notebook paper to the front of your phone book because you are likely to be interested only in a small subset of the information contained in the book and just as likely to be interested in the same information time and time again. Sounds perfect, right? But the analogy is flawed. Static content on a website is like a phone book, but imagine how difficult it would be to use your "paper cache" if the numbers inside the phone book constantly changed or if numbers differed based on who was looking them up. This is why caching dynamic content poses a more difficult problem than caching static content.
One misconception about caches is due to the misalignment of the computing-centric definition and the English definition of the word cache. In English, a cache is a place to store things often out of sight or in secret, and that definition assumes that it will be there when you return for it. A computer cache is only meant to speed acquisition of data; if it is missing when you look for it, you incur what is called a cache miss. This miss costs you nothing but time.
Caches are everywhere, from the "registers" on your CPU to L1/L2 CPU cache to disk drives to name servers to web systems–and the list goes on. Caches are fundamental engineering tools both inside and outside technology. If they are everywhere, how do you tell if a cache is a web cache? Let's define our web architecture as components directly creating browser-digestible content. This definition eliminates many architectural components that use caches: load balancers, databases, networking equipment, disk drives, and so on. This leaves us with web servers and application servers (glorified web servers).
Web servers are squished right in the middle of our spectacular architectural sandwich. Web caches are caching components of any type that operate directly on web servers or between web servers and their adjacent layers as depicted in Figure 7.1.
Performance Tuning Has Its Limits - Why are we talking about caching and not application performance tuning? This is an important question and deserves attention. Our goal is to demonstrate techniques that can be used as building blocks for scalable systems–and caching is such a technique. Application tuning can only increase performance, and you'll note that the title of this book is not High Performance Internet Architectures. That is not to say that the concepts herein do not perform well, but rather that they focus on scalability and leave high-performance programming, tuning, and tweaking to other books.
Why are scalability and performance different? This is explored in detail in the introduction, but it deserves a few more words. No matter how fast you make your application, you will be limited if it does not scale horizontally.
To put it another way, if your application performance can be increased by 10%, 5%, or perhaps 1% by doubling your hardware, you are in big trouble. Moore's law says that your computer will be twice as fast in 18 months, so if you want to double your capacity, call me in a year and a half. On the other hand, if your application and architecture are designed to be able to leverage 60% or more performance by doubling your architecture, you can scale your system up today. Those percentages are arbitrary, and each architecture will have its own horizontal scaling efficiency. 100% means a perfectly (horizontally) scalable architecture, and 0% means an architecture that scales vertically, so performance tuning is your only option–so aim high.
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
- Dynamic DNS—an Object Lesson in Problem Solving
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Using Salt Stack and Vagrant for Drupal Development
- New Products
- Drupal Is a Framework: Why Everyone Needs to Understand This
- Validate an E-Mail Address with PHP, the Right Way
- New Products
- Download the Free Red Hat White Paper "Using an Open Source Framework to Catch the Bad Guy"
- The Secret Password Is...
- A Topic for Discussion - Open Source Feature-Richness?
- myip
2 hours 43 min ago - Keeping track of IP address
4 hours 34 min ago - Roll your own dynamic dns
9 hours 47 min ago - Please correct the URL for Salt Stack's web site
12 hours 58 min ago - Android is Linux -- why no better inter-operation
15 hours 14 min ago - Connecting Android device to desktop Linux via USB
15 hours 42 min ago - Find new cell phone and tablet pc
16 hours 40 min ago - Epistle
18 hours 9 min ago - Automatically updating Guest Additions
19 hours 18 min ago - I like your topic on android
20 hours 4 min ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?




Comments
Cookie storage
Thanks for this good summary.
I have got some problems with cookie caching, because only small informations can be stored in cookies and this form of caching could come together bandwith problems on the client side.
So I think it can be better a combination of cookies and server caching. For example: A user comes and first time I read the cookie, and the next page query I can use serverside cache (created from cookie's datas). I change the cookie only when the user change his preferences.
In this example the process seems so:
1. I check the serverside cache, if found, then ok, else
2. I check the cookie, if found and valid, then ok, else
3. I get the informations from the database and write in cache and in cookie
And 30 minutes after the last page query (same as by sessions) the serverside cache can be invalidated by a timer.
Same problem
My programmer Adam had the same problem. He figured out a compact way to server over 53 million of our blog articles on one little server.
The speed is awesome and googlebot is busy busy.. my blogs
~Ray
Good Summary
Some of the technics are often used, but this article is a good summary for caching dynamic pages and content.
What an article! Sure beats
What an article! Sure beats the caching concepts discussed in my University's computer architecture class. Can't say that I manage web sites with enough traffic to need such levels of performance refining, but it sure is fun to learn.