⏱
Network performance • API response analysis • Timing breakdown
HTTP request timing includes DNS lookup, TCP handshake, TLS negotiation, and response time.
Key timing phases:
Performance Thresholds: Excellent (<100ms), Good (100-300ms), Fair (300-600ms), Poor (>600ms)
Optimizing request timing improves user experience and API performance.
HTTP requests go through several distinct phases:
Performance thresholds for web applications:
Effective optimization techniques:
Measurement of time taken for HTTP requests to complete.
DNS → TCP → TLS → Request → Response
Total = Sum of all phase durations
Quantitative measures of request efficiency.
Which of the following correctly lists the phases of an HTTP request in chronological order?
The correct answer is B) DNS Lookup → TCP Handshake → TLS Negotiation → Request Processing. The HTTP request process begins with resolving the domain name to an IP address (DNS lookup), then establishing a TCP connection (handshake), followed by setting up an encrypted connection if HTTPS is used (TLS negotiation), and finally sending the request to the server for processing.
Understanding the sequential nature of HTTP requests is crucial for performance analysis. Each phase must complete before the next can begin, creating a dependency chain. This is why optimizing the earliest phases (like DNS lookup) can have cascading benefits throughout the entire request lifecycle.
DNS Lookup: Resolving domain name to IP address
TCP Handshake: Three-way handshake (SYN, SYN-ACK, ACK)
TLS Negotiation: Establishing encrypted connection parameters
• Each phase must complete before the next begins
• DNS lookup happens first in the process
• TLS negotiation only occurs for HTTPS requests
• Remember: Domain resolution comes first
• Connection establishment follows
• Encryption negotiation (if needed) comes next
• Confusing the order of request phases
• Forgetting that DNS lookup happens first
• Not understanding that TLS is conditional
Calculate the total request time given the following timing measurements: DNS lookup: 25ms, TCP handshake: 30ms, TLS negotiation: 120ms, Request processing: 180ms, Response transfer: 45ms. What is the total time and performance rating?
Calculation of total request time:
DNS lookup: 25ms
TCP handshake: 30ms
TLS negotiation: 120ms
Request processing: 180ms
Response transfer: 45ms
Total time = 25 + 30 + 120 + 180 + 45 = 400ms
Performance rating: 400ms falls in the "Fair" category (300-600ms)
Answer: Total time = 400ms, Performance rating = Fair
This calculation demonstrates how individual timing phases contribute to the overall request time. Understanding this breakdown helps identify which phases are consuming the most time and where optimizations would be most beneficial. In this case, request processing and TLS negotiation are the largest contributors.
Total Request Time: Sum of all timing phases
Performance Rating: Classification based on total time
Phase Contribution: Individual impact of each timing phase
• Total time is the sum of all phases
• Each phase contributes to the overall time
• Performance ratings are based on total time
• Always add all phases to get total time
• Identify the largest contributing phase
• Compare to performance benchmarks
• Forgetting to include all timing phases
• Incorrectly adding the values
• Misapplying performance thresholds
An API request takes 850ms to complete with the following breakdown: DNS lookup: 5ms, TCP handshake: 15ms, TLS negotiation: 95ms, Request processing: 680ms, Response transfer: 55ms. Identify the bottleneck and recommend specific optimizations.
Bottleneck identification:
Request processing: 680ms (80% of total time) - This is the bottleneck
Phase breakdown:
- DNS lookup: 5ms (0.6%)
- TCP handshake: 15ms (1.8%)
- TLS negotiation: 95ms (11.2%)
- Request processing: 680ms (80%)
- Response transfer: 55ms (6.5%)
Recommendations:
1. Optimize server-side processing logic
2. Implement database query optimization
3. Add caching for frequently accessed data
4. Scale server resources if needed
5. Optimize algorithms and reduce computational complexity
This example demonstrates how to identify performance bottlenecks by analyzing the proportion of time each phase consumes. When one phase dominates (like request processing at 80%), it becomes the primary target for optimization efforts. The other phases, while important, contribute minimally to the total time.
Bottleneck: Phase consuming disproportionate amount of time
Performance Analysis: Identifying time-consuming phases
Optimization Target: Phase offering greatest improvement potential
• Focus optimization on the largest time-consuming phase
• Calculate percentage contribution of each phase
• Prioritize optimizations based on impact
• Calculate percentages to identify bottlenecks
• Focus on phases that consume 50%+ of time
• Re-measure after implementing optimizations
• Optimizing minor phases instead of bottlenecks
• Not calculating percentage contributions
• Applying generic optimizations without analysis
How would a 10x increase in network latency (from 20ms to 200ms) affect the timing breakdown of an HTTP request that currently takes 350ms with DNS: 20ms, TCP: 30ms, TLS: 80ms, Request: 150ms, Response: 70ms? Calculate the new total time.
Current timing breakdown:
DNS: 20ms, TCP: 30ms, TLS: 80ms, Request: 150ms, Response: 70ms
Total: 350ms
Effect of increased latency:
Latency primarily affects DNS lookup, TCP handshake, and response transfer
New timing estimate:
DNS: 20ms → ~30ms (increased due to latency)
TCP: 30ms → ~230ms (significantly increased due to latency)
TLS: 80ms → ~250ms (increased due to multiple round trips)
Request: 150ms → 150ms (server processing unchanged)
Response: 70ms → ~270ms (increased due to latency)
New estimated total: ~830ms
The request would move from "Good" to "Poor" performance category.
This analysis shows how network conditions disproportionately affect connection-establishment phases (TCP, TLS) and data transfer phases (response). The request processing time remains unchanged since it occurs on the server side. Network latency has a multiplicative effect on phases requiring multiple round trips.
Network Latency: Time for data to travel between client and server
Round Trip Time: Time for request and response to complete
Connection Establishment: Phases requiring multiple network exchanges
• Latency affects connection phases more than processing
• Multiple round trips amplify latency impact
• Server processing is independent of network latency
• Use connection pooling to reduce handshake overhead
• Implement HTTP/2 for better connection utilization
• Consider CDN for geographic optimization
• Assuming all phases are equally affected by latency
• Not considering round-trip amplification
• Ignoring the impact of geographic distance
Which optimization strategy would provide the greatest performance improvement for an HTTPS API request with the following timing: DNS: 50ms, TCP: 40ms, TLS: 200ms, Request: 120ms, Response: 80ms?
The answer is B) HTTP/2 implementation. Looking at the timing breakdown: DNS: 50ms, TCP: 40ms, TLS: 200ms, Request: 120ms, Response: 80ms. The TLS negotiation (200ms) is the largest component. HTTP/2 allows connection reuse and can significantly reduce the overhead of subsequent requests by eliminating repeated TLS negotiations. While server optimization would help with the request processing time, HTTP/2 would provide broader benefits across multiple requests.
This question demonstrates the importance of looking beyond just the largest single component. While server optimization would improve the 120ms request processing time, HTTP/2 implementation provides systemic improvements by reducing connection establishment overhead, especially for multiple requests. It also allows for multiplexing and server push capabilities.
HTTP/2: Protocol enabling multiplexed requests over single connection
Connection Reuse: Using existing connections for multiple requests
Multiplexing: Sending multiple requests simultaneously over one connection
• Address the largest time-consuming phase first
• Consider systemic improvements over point fixes
• HTTP/2 reduces connection establishment overhead
• Implement HTTP/2 for connection optimization
• Use connection pooling for repeated requests
• Consider HTTP/3 for further improvements
• Focusing only on the absolute largest component
• Not considering systemic improvements
• Ignoring the benefits of protocol upgrades
Q: How do connection pooling and keep-alive affect request timing, and when should I use them?
A: Connection pooling and keep-alive work differently:
Benefits:
Use them for applications making multiple requests to the same server, especially APIs and microservices architectures.
Q: What are realistic expectations for API response times in different network conditions?
A: Realistic API response time expectations:
These times include network overhead. Server processing should be significantly less than total time for optimal performance.