5

So I have got an application that during various steps during a user's process will transmit and receive data from external API's.

Currently the way this is handled is fairly rudimentary. There will be a POST, DELETE, or PUT to the app. The application will then make the necessary updates in the DB and submit any information to the API's we are using. After we get responses from the DB and API we respond to the user's request.

When I started with the application the external services we were using were small, however after working on it for a few years, the number has been growing. After working with a particularly painful API that has slow response times, I'm finding that this response to the user's request is starting to feel slow and painful.

How does one handle interacting with slow external services?

Now on a higher level, I know that one solution would be to implement a queue-like system for these API's where the calls are pushed into a queue and a separate process / service processes them. Update the DB, fire off the API updates to the micro-service and call it a day. Are there any other approaches for handling this sort of situation?

5
  • Sorry that the tags aren't that great, I'm not sure on what tags would be appropriate here. Jan 7, 2015 at 17:33
  • 1
    Without knowing the details, the question is impossible to answer. Maybe you should simply switch to an API of a competitor, or roll your own. Maybe caching the results is the answer. Maybe you are requesting too much information from the API or do too many unneeded requests... Jan 7, 2015 at 17:40
  • Sorry, let me flesh out the API call situation. Generally we are not pulling information from these API's; 95% of the time we are sending our data to them. Switching to a competitor that offers faster API responses isn't really a viable alternative due to vendor lockin. Jan 7, 2015 at 17:49
  • 1
    The obvious solution to your apparent problem is to call the external API asynchronously. Jan 7, 2015 at 18:37
  • 1
    The API calls are all being done asynchronously, however the response to the request is only being called after the external calls have been completed. I suppose that I could handle some of this by getting the POSTed data, updating the DB, responding to the POST while at the same time contacting the API's, but that then raises the question of how to notify the user in case of errors. I suppose that question would also have to be answered in a queue-like setup as well though. Jan 7, 2015 at 19:06

1 Answer 1

3

Calling the external API asynchronously is the best bet.

When it is part of a user's process, it is best to show feedback that the call is underway and some indication whether the call finished and succeeded or failed once you get response. If possible, let the user give other input while waiting for feedback on the external API, this negates the "slow and painful" feeling.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.