Unlike bottlenecks such as memory shortage that can be relatively cheaply addressed by adding hardware to the web server, upgrading or adding CPUs is relatively expensive. That makes it attractive to first try to reduce CPU usage when confronted by a CPU-related bottleneck.
In this chapter, we'll discuss the following:
Let's start off with identifying where your code incurs the greatest CPU usage.
There are a number of techniques to identify pieces of code with high levels of CPU usage: