Modern systems integrate with a lot of external dependencies. Most of these dependencies are outside our control. While requesting content from one of them, it could happen that it does not reply our requests. Even worse would be if it decides to answer our requests at a rate of one byte per second!
What could we do in this case? That is where Timeouts comes to rescue!
Although this technique has been around for decades, developers still don’t provide sane
Timeout values most of the time. It then becomes the burden of the Operating System, Virtual Machine or framework.
One major problem that might arise from this is:
- An external dependency faces difficulties answering requests.
- Our system makes tons of requests to this external dependency.
- Our system accumulates tons of threads waiting for a response, that might never come.
- As it accumulates more and more waiting threads it becomes unable to handle new requests.
- Eventually our server crashes due to insufficient memory.
It does not seem too much asking developers to define a
Timeout value for external requests. In case you are developing using
Node.js, as I am right now, it might be as easy as:
In case you are interested in learning more about
Stability Patterns, read Michael T. Nygard’s book Release it!. It inspired me writing this short blog post.