Patterns of Performance Improvement

Performance improvements can be grouped into patterns which are generalizations of the way things tend to work rather than concrete advice. Here are some patterns which unify performance improvement techniques, each with three examples.

Amortization

Performance improvements often involve amortizing overhead among many transactions for an economy of scale:

  • HTTP 1.1 allows a single TCP connection to be reused for multiple file downloads. This feature is known as persistent connections. The overhead of setting up and tearing down a TCP connection is spread among several files rather than reincurred for each file.

  • Java .jar files work in a similar way, grouping Java .class files together into a package that can be downloaded in one TCP connection rather than setting up a separate TCP connection for each class. The downside here is that the .jar file may include classes you never use.

  • A composite imagemap is another example. Rather than sending multiple small images to the user, send a single large image. If the original individual images were clickable, you can maintain the same functionality by making the large image a clickable imagemap.

Caching

Caching is the most important and widespread performance technique. The idea is simple: keep frequently accessed data close at hand. Caching helps only if some data is in fact more frequently accessed than other data, but this is usually the case:

  • You can often trade storage space for more performance by running ...

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.