Chapter 10. Principles and Patterns

There are some principles of performance tuning that apply in the general case and some patterns that unify the specific solutions. In this chapter, I try to summarize these principles and patterns.

Principles of Performance Tuning

The following sections cover some general principles of performance tuning.

Sometimes You Lose

You don’t know whether you can improve the performance of a system until you study it, but you risk wasting your time just figuring out that there’s nothing you can do, particularly when you are under tight budget or time constraints. You have to weigh the probable difficulty of the analysis against the potential gains. If the gains could be very large, it is a good bet to try to improve performance, but otherwise it’s not worth your time.

To Measure Something Is to Change It

The physicist Werner Heisenberg pointed out that measuring anything changes it, if only slightly, so there is some uncertainty to all measurements. This is called the uncertainty principle, and is definitely true when measuring computer performance.

The classic example is running ps to see which processes are running on your server, and noticing that the only thing you ever see in the run state is ps itself. This must be so because ps has to be the running process in order to check which process is currently running. Similarly, when you take performance measurements on a machine doing some work, you are necessarily measuring not only the load of the work, ...

Get Web Performance Tuning, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.