Web Technology Basics
From a web server with an RTT of 40 ms, one HTML file and the four images it references are fetched one after another. Assume that establishing a TCP connection takes one round trip and each request and response take one round trip, and ignore data transfer time, server processing time, TLS and connection teardown. Which of the following is the difference in total time between opening a new TCP connection for each object and reusing one TCP connection (a persistent connection)?
- A160 ms
- B200 ms
- C400 ms
Show answer and explanation
Answer: A. 160 ms
There are five objects in total. With a new connection each time, each object takes two round trips, one for connection setup and one for the request and response, giving 5 × 2 × 40 = 400 ms. With a persistent connection, the connection is set up only once at the start, followed by just the five requests and responses, giving (1 + 5) × 40 = 240 ms. The difference is 400 − 240 = 160 ms, which is the four connection setups saved. In HTTP/1.1, persistent connections are the default behavior.
- A. Correct. 400 − 240 = 160 ms; four connection setups are saved.
- B. This takes the five connection setups, 5 × 40 = 200 ms, as the difference. Even a persistent connection needs one connection setup at the start.
- C. This is the total time when connecting each time, 5 × 2 × 40 = 400 ms, not the difference.