There can be many reasons why Shop Servers can become slow and unresponsive. Maybe they are reaching their resource rate-limit, too busy handling other requests .etc. So at your app side, We can only alleviate the above situations by applying timeouts-retries-and-backoff when calling API.
For handling call API when app inactive You should to register a webhook event app.activated/app.deactivated with your app, to determine when your app call or should not call with shop API.
Hope that helps.