0

Say I have service http://myservice.dev:8080/resource/get/id which calls another service http://otherservice.dev:8080/resource/get/name. If the second service does not respond because it is down, what is the proper response the calling service should return to the client? Assume that it is critical for the request to call the second service.

I was thinking 504 gateway timeout but it sounds like this is for the upstream gateway...

Matt
  • 5,408
  • 14
  • 52
  • 79

1 Answers1

1

TL;DR Yes, 504 would be appropriate in most cases

The definition of upstream server is important:

In computer networking, upstream server refers to a server that provides service to another server. 1

So in the case you mention, yes, the 'otherservice' can be considered an upstream server and thus HTTP response codes like 502 and 504 would be appropriate.

That being said, depending on your use case, it is perhaps not wise to expose information to your client about the upstream servers. It may be irrelevant to clients as to how many other services are dependencies. Especially if you re-architect or reconfigure in the future, the 'otherservice' may become part of the 'myservice'. And thus a failure should be appropriately tagged as 500 (Internal Service Error) or 503 (Service Unavailable).

1 https://en.wikipedia.org/wiki/Upstream_server

Edgar
  • 1,174
  • 8
  • 9
  • I am under the impression that the other service would be considered downstream. The gateway would be the upstream server (in this case the highest server may be the service that calls the other service). We usually do have a gateway setup upstream of our tomcat boxes as well. I suppose that 500 may just be the best response in this case. – Matt Apr 24 '16 at 07:47