Error Response Handling
This section details a simple paradigm for error response handling.
Applications based on request/response pairs may face a myriad of issues because of network and internet connectivity causing request timeouts due to network throttling and overloading. Many hardware problems, such as load-balancer faults and switch timeouts, can also cause transparent request timeouts. For these reasons, an application using the Apstrata database service should implement a request retry strategy.
The following is an example of a simple strategy for exponential back-off in request retries. The back-off strategy is dependent on the application’s business needs. It stops retrying a request after 5 tries in order to avoid network congestion:
nRetries = 5 for (i=0; i<nRetries; i++) { response = Make the request if ((response is success) OR (response is a client error)) { return the response } // Response was a server error // Delay the next request by waiting wait(4 ^ i * [Random number between 1 and 2] * 100 milliseconds) }
Client/Server Errors
Do not retry client errors. Client errors indicate that Apstrata found a problem with the client request and the application should address the issue before submitting the request again. You should, however, retry requests if server errors occur.