I have a system which needs to send requests to an external system, whenever a user does search on my system.
If the external system is down or is taking an unusually long time to answer, I would like my system to "back off" for a while. Instead of trying to make more requests to the external system, I want to just let the user of my system know immediately that we will not be processing their requests at the moment.
This would result in a better experience for the user (doesn't have to wait for timeouts), less resource usage in my system (threads won't be busy waiting for no responses or timeouts from the external system) and it would spare the external system. (in a situation where it probably is already struggling with load)
After some time, or when my system discovers that the external system is responding again, I would like to resume normal behaviour again.
Is there any patterns or standard ways of doing this kind of thing? Specifically the mechanism for keeping track of timed out/long requests, and some sort of control mechanism for when we should start trying again.