Course contentsShow
← System Design
Lesson 1090 of 1,91928. Timeouts and DeadlinesFree lesson

Client-Side vs Server-Side Timeouts

How timeouts apply differently from client perspective (waiting for response) versus server perspective (processing limits).

Client-Side vs Server-Side Timeouts

What you'll learn: How timeouts operate differently when enforced by the client waiting for a response versus the server limiting its own processing time.

Two Perspectives, Two Timeout Roles

When a client makes a request to a server, timeouts can be applied from both ends of the connection, and they serve different purposes:

  • Client-side timeout: The maximum time a client will wait for a response before giving up
  • Server-side timeout: The maximum time a server allows itself to process a request before abandoning work

These are independent mechanisms that protect different parts of the system.

The Client Perspective

A client-side timeout is about managing your own patience. You set a deadline for how long you'll wait for an answer. If the server takes too long (maybe it's overloaded, crashed, or stuck), your timeout fires and you stop waiting. This prevents your application from hanging indefinitely.

Think of it like waiting for an elevator: you decide "I'll wait 2 minutes, then take the stairs." The elevator doesn't know about your personal deadline.

The Server Perspective

A server-side timeout is about self-protection and resource management. The server decides how long it will spend processing any single request before killing that work. This prevents one slow request from consuming resources forever and starving other requests.

This is like a restaurant kitchen saying "we'll spend maximum 20 minutes on any dish, or we cancel it" — even if the customer is still patiently waiting.

Why Both Matter

These timeouts work together but solve different problems:

  • Client timeout protects the caller from waiting too long
  • Server timeout protects the server from doing too much work
  • A request can hit either timeout (or both!)

Key Takeaway: Client-side timeouts guard the requester's time and prevent hanging; server-side timeouts protect the server's resources and prevent runaway processing — both are essential defensive mechanisms in distributed systems.