With the necessity to use networking in an app and with limited choices for minimizing latency (e.g., using CDNs or edge servers or using smaller payload formats like Protobuf or data compressions), everything gets down to best utilizing the available network conditions and planning ahead for varying scenarios.
In this chapter, we look at the factors that impact the overall latency and how you can make best use of the information available to maximize performance.
Most of the work done in networking is outside of your control, so it is important to identify the metrics to measure. We will discuss some of the more important performance-related metrics in this chapter. Note that this is not intended to be a comprehensive list, but just to point out the more important ones to measure in relation to optimizing performance.
Figure 7-1 shows a bird’s-eye view of a typical request over the network.
The general structure of the discussions that follow is a description of the metric of concern, one or a couple of examples, followed by best practices.
The first step to initiating a connection is DNS lookup. If your app is network heavy, DNS lookup times can slow it down. In a rigorous statistical sample of two locations, DNS lookup time to the host www.google.com from Sunnyvale, California, ...