Causes of performance issues

Whenever a user experiences performance problems, it is because he has exceeded the capacity of one of his system resources, either bandwidth memory or processing power. Before debugging any performance issue, it's essential to understand which of these factors is responsible, and this can be determined in one of two ways. First, a profiling tool (such as the tools included with all major browsers) can be used to measure how much of each resource is being used, which should quickly make obvious which resource is being used excessively. An explanation of these tools falls outside the scope of this book, but I strongly encourage you to familiarize yourself with the tools available in your favorite browser.

For most problems, however, a profiling tool won't even be necessary, because their source can be determined by how they manifest. Bandwidth problems only occur when retrieving or sending data from your server (and in most applications, only retrieval operations involve enough bandwidth to be problematic). If they occur at load time, then they could be caused by a significant number of large static resources, such as images, but if they occur afterwards, they are far more likely to be the result of AJAX calls. In Backbone applications, this means fetch operations (or, rarely, save or destroy operations) from Models or Collections.

CPU performance issues only occur when the user's computer is forced to think hard about something you are making it do. For example, a series of nested for loops, or the rendering of a complex visualization such as a chart can cause such performance issues. This type of performance issue is usually easy to identify because it only occurs when the user triggers such computationally intensive code.

The final, and by far the most difficult, source of performance issues is the memory. Unlike the other two issues, which usually have obvious triggers such as the start of an AJAX operation or the rendering of a chart, memory issues can occur without any clear or obvious source. In fact, memory issues can begin seconds or even minutes before the user actually starts noticing problems, forcing you to trace back through all the code they hit to try and find a cause. Because memory issues are the most common type, and because they are the hardest to understand and resolve, we will be focusing most heavily on them in this chapter. However, before we do so, let's examine the other two sources, and some common sense approaches to avoiding them.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.87.196