Latency is the delay before data transfer begins, often measured as the round-trip time (RTT) for a request to travel to a server and back.
Types of latency
Network latency
- Time for data to travel between client and server
- Affected by distance and network quality
- Typically 20-200+ milliseconds
Server latency
- Time for server to process a request
- Affected by server load and code efficiency
- Database queries, computations
Rendering latency
- Time for browser to process and display content
- Affected by JavaScript execution
- DOM parsing and painting
Measuring latency
- Ping: Basic network latency test
- TTFB: Includes server processing time
- RTT: Round-trip time for full request/response
Reducing latency
- Use a CDN to reduce distance
- Optimize server-side code
- Use efficient database queries
- Enable HTTP/2 or HTTP/3
- Reduce number of requests
Related Terms
Caching
The process of storing copies of data in a temporary storage location so that future requests can be served faster.
Content Delivery Network (CDN)
A geographically distributed network of servers that work together to provide fast delivery of internet content by serving it from locations closer to users.
Server Response Time
The time it takes for a server to respond to a request from a browser, measured from request initiation to receiving the first byte of response.
Time to First Byte (TTFB)
A performance metric that measures the time between the request for a resource and when the first byte of a response begins to arrive.