0

I have a Java back-end, which itself consumes many web-APIs through HTTP requests. In one transaction, I may query 3 or 4 APIs issuing 20-30 requests for each of them.

Sometimes, the APIs are either down or under pressure causing my code to timeout or slow down in the best case. The effect multiplies, since I have a upper limit on the parallelism in issuing the requests. This in turn badly affects the responsiveness of the front end of my application.

Is there a Java library or framework which may help me detect times when a certain API is repetitively timeout or slowing down? or maybe a framework to monitor the "health" of the APIs? This would allow me to stop issuing requests to the slow/timing out/offline API for some time or for a specific transaction, thus saving waiting time.

Bahaa
  • 1,577
  • 18
  • 31
  • http://stackoverflow.com/questions/19819837/java-executor-with-throttling-throughput-control something like this? – Taylor Oct 21 '15 at 18:39
  • Nope @Taylor. I'm concerned with detecting failures caused by foreign reasons on foreign APIs I'm querying. Let's say, API X comfortably replies within a maximum of 500ms and can serve up to 20 simultaneous requests with no problems. If for some reason, API X is down or is exceptionally slow to the extent it would timeout, those 20 requests will cost 10 seconds per transaction. Since, I query 3 to 4 APIs in one transaction and I do so frequently, I would like to detect such a situation and act accordingly (maybe, skip the calls for API X for some time) to reduce the impact on performance. – Bahaa Oct 21 '15 at 19:23
  • The only way you'll know if API X is "slow" is to measure the duration from when you submit the HTTP request to when you receive the response. It's up to you to measure the duration, determine what's "slow", and have your application respond. – Gilbert Le Blanc Oct 21 '15 at 19:42
  • 1
    That's right, @GilbertLeBlanc. I can write my own code, but my question is: Is there an existing Java library/framework, which facilitates that? – Bahaa Oct 22 '15 at 08:15

0 Answers0