I assume you want to restart the server if most of the response takes more than x seconds. There are many tools available to help you restart your instances based on their health. Monit is one of them. In this guide, monit restarts the instance if the response does not return after 10 seconds.
, , - , , , , . , , , , , . , , .