Skip to content
IT glossary
BackendUpdated December 3, 2026

Timeout

Таймаут

A timeout limits how long a program will wait for an operation or one of its steps. When that time runs out, the program stops waiting, but the underlying work may still continue.

Why timeouts matter

Suppose a product page calls a recommendations service. If recommendations take too long, the page can return without them. A timeout makes that choice possible: instead of waiting for an answer that might never arrive, the caller moves on. This also helps protect backend capacity. Slow calls can tie up connections, workers, or memory even when the caller is doing nothing but waiting. Engineers use timeout both for the configured limit and for the event that occurs when it expires.

Check what the timer actually measures

A connect timeout limits how long the client waits to establish a connection. A read timeout often limits how long a read can wait for more data, not how long the entire download may take. A server that keeps sending small chunks can therefore stay below the read timeout while taking much longer to finish. An overall timeout covers the full operation as defined by the client library. Check the documentation before assuming that includes redirects, waiting for a pooled connection, or retries performed by your own code.

A timeout is usually a duration; a deadline is the point by which work must finish. Say an API has 500 ms to answer and has already spent 300 ms getting the account record. The next dependency has less than 200 ms available if the API also needs time to assemble and send the response. Giving each call a fresh 500 ms timeout defeats the original budget. Passing a deadline or the remaining time downstream lets each service make that calculation.

Example: did the order go through?

A client sends POST /orders and times out before receiving a response. The server might never have received the request, or it might have saved the order before the response was delayed. Closing the client connection does not guarantee that the server stops or rolls anything back. Where the API supports idempotency keys, a retry with the same key lets the server recognize the same operation and avoid creating a duplicate order. Without that protection, a timeout alone is not a reason to retry a write blindly.

Choosing a limit in production

Start with the latency users can tolerate and measure how long the dependency normally takes, including the slow end of the distribution. A limit that is too short cuts off healthy requests; retries can then make an already busy service busier. A limit that is too long leaves more requests in flight when a dependency slows down. Track where time is spent: waiting to borrow a connection from a pool calls for a different investigation than waiting for a database statement to finish. If retries are appropriate, count both the attempts and the pauses between them against the original time budget.

Interview angle

“Does a timeout mean HTTP 504?” is a useful test of which component stopped waiting. If the HTTP client hits its own limit, the application may get a local timeout error and no HTTP response at all. 504 Gateway Timeout is an actual response from a gateway or proxy that did not get a timely response from an upstream server. In a system design interview, explain which layer enforces each limit, what the caller returns when it expires, and whether anything cancels the work already in progress.