May we use cookies so Meta, Google, LinkedIn and ChatGPT see your visit and we learn which ads work? PrivacyMay we use cookies to see which pages help, and let Meta, Google, LinkedIn and ChatGPT see your visit, so we know which of our ads work? That way we spend less on ads that do not work. We do not sell your data, and the site works the same if you decline. You can change your answer at any time under Cookie settings at the foot of the page. Privacy policy
Loading...
System Design Masterclass · Core Fundamentals
Free preview: the first 2 parts of this 6-part lesson.
Already bought the course? Sign in to read the whole lesson.
this lesson is part of
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$35 once, by card or PayPal
See the System Design courseread the rest of this lesson in
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$35 once, by card or PayPal
See the System Design coursein Core Fundamentals
This lesson is part of the full System Design Masterclass. Unlock it along with 769 other lessons for a one-time payment.
One-time payment by card or PayPal
Get Lifetime AccessOne-time payment: UPI, card or netbanking
Get Lifetime Access18 Foundation lessons are free, no payment needed. Try them now
It is easy and good
“It is really nice and good Please join the course”
You dial someone's number. It rings. And rings. And rings. After about 30 seconds, you hang up. Nobody answered, no point waiting forever.
That decision to hang up after 30 seconds? That's a connection timeout.
In software, a connection timeout is the maximum time your application will wait to establish a connection with another service before giving up. Not the time to get a response, just the time to confirm the other side is even there and willing to talk.
This matters more than most developers realize. Here's a scenario: your web app calls a payment service. The payment service's server is down, not returning errors, just completely unreachable. Without a connection timeout, your app would wait. And wait. And wait. Meanwhile, the user is staring at a spinner. Your server thread is stuck. As more users hit the same codepath, more threads get stuck. Eventually, your entire application hangs because all threads are blocked waiting for a dead service.
A missing connection timeout is one of the most common causes of cascading failures in production systems. The fix takes one line of code. The outage it prevents can save your company hours of downtime.
Before any data is exchanged between a client and a server, they perform a handshake, a three-step process to establish a connection.
This entire handshake typically takes 1-100ms depending on network distance. If the server is in the same data center, it's under 1ms. If it's across the ocean, maybe 50-100ms.
The connection timeout is the maximum time you'll wait for that SYN-ACK. If the server never responds, because it's down, the network is broken, a firewall is blocking traffic, or the server is so overloaded it can't accept new connections, your client gives up after the timeout and throws an error.
This is an important distinction that many developers confuse:
| Timeout Type | What It Covers | Typical Value |
|---|---|---|
| Connection Timeout | Time to establish the TCP connection (the handshake) | 1-5 seconds |
| Read/Request Timeout | Time to receive a response after the connection is established |
| 5-30 seconds |
The connection timeout is almost always shorter than the request timeout. If the server isn't reachable, you want to know fast. But once connected, the server might legitimately need time to process your request.