Fail fast

This is an important concept in today's world, where performance is of the utmost importance. A very simple example would be that you hit a link on a website, it starts loading the page, shows you a loader on a blank page, you wait patiently for seconds or maybe for minutes, and then you get the message Could not retrieve data, please try again later. It's like rubbing salt in a wound. If you had to show the error message, why did you make the user wait?

So if the service has to fail, it should fail fast. But how do we achieve that? There are multiple ways, based on your service. If your service is going to call another service, you can keep a check on the health of the other service, maybe by a handshake or ping call, so you are aware of the fact that the other service is in a position to handle your calls.

An additional approach is the use of the bounded queue. Any request reaching to the service is queued, and this queue is bounded. So, if we know that our service can handle 10,000 calls in an acceptable amount of time without getting slow, we will only queue 10,000 requests and then reject additional requests. This way, the additional calling services can retry after some time and do not get blocked.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.117.191