Chapter 5. Principles and Patterns

If you ask any computer consultant for a concrete solution to a general problem, you will inevitably get the reply that each situation is different and that more information is needed before advice can be offered. While it is true that a specific solution can’t be given without detailed knowledge of the problem, there are also some principles of performance tuning that apply in the general case and some patterns that unify the specific solutions.

Principles of Performance Tuning

Sometimes You Lose

You don’t know whether or not 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 caused by the act of measuring. This is called the uncertainty principle, and is certainly true when measuring computer performance. The classic example is running ps -aux to see what 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 ...

Get Web Performance Tuning 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.