How it works
In AI applications, network latency adds up the time to send the prompt, processing on the server, and returning the response. Factors include physical distance, connection quality and server load.
For agents that make multiple API calls, latency accumulates. An agent that makes 5 sequential calls with 200ms latency each will have at least 1 second of wait just from network.
Latency is not the same as throughput. Latency is the time for one request. Throughput is how many requests per second the system processes. A system can have high latency and high throughput (processes many requests, but each one takes a while).
Practical example
An agent that makes 5 sequential calls to an API with 200ms latency each will have at least 1 second of wait just from network. Reducing latency (using closer servers or parallel calls) improves the experience.
For real time chatbots, high latency causes a poor experience. The user types and waits several seconds for the response. Solutions include streaming (sending tokens as they are generated), response caching and geographically close servers.
What it's for
Optimize AI applications, choose deployment regions and design efficient agents. Understanding latency helps decide between remote API and local model, and to design flows that minimize sequential calls.
For developers, this means measuring latency in production and optimizing bottlenecks. For architects, it means choosing infrastructure based on response time requirements.
Difference between latency and throughput
Latency is the time for a single request to go and come back. Throughput is how many requests the system processes per second. A system can have low latency and low throughput (responds fast, but few requests). Or high latency and high throughput (takes long, but processes many at the same time).
In AI, batching increases throughput but can increase latency (the request waits for the batch to form). Streaming reduces perceived latency (the user sees tokens as they are generated) without changing total latency.