I'm designing a REST solution for remote communication with a number of servers that exist on a different network. Some of the calls are relatively short, while others can take minutes. The calls are synchronous in nature, so that if the call is asynchronous, the client (actually a server) must poll for the response. Polling is suboptimal in that it incurs a performance hit and delays the response to the end user by a frac开发者_运维知识库tion of the polling interval. I would prefer to use synchronous calls, but if a network connection is dropped there is no recourse to get the response. If asynchronous, the remote server can return a job id, which can be polled, and survive intermittent network issues. Retry and idempotency are important considerations.
I'm looking for some recommendations on which approach to take. We also have calls that are initiated by the remote server. These will go through a load balancer for HA. I'd also be interested in some book recommendations that describe best practices for entreprise communication in a HA environment. I can't seem to find anything that covers this topic.
You could design a synchronous system that supports "reconnect" in the event of a network failure. The reconnect call would be a way for the client to "re-attach" to the same call. If the server happened to have completed the call between the disconnect and reconnect, the return value would have been saved and could be returned immediately when the reconnect comes in. To support reconnect, calls need to be assigned an identifier. The identifier can be chosen by the client as a guid and passed as part of the initial call to the server. The server then associates this guid with the call. Upon a disconnect and reconnect, the client passes the same guid and the server uses this to reattach the client to the call. The saved values as described above would probably need some kind of time-to-live duration before they get purged from the pool. What do you think?
精彩评论