We keep all datacenters separate regions, so there is no automatic load balancing or fail-over. Thus we recommend all users that they add automatic fail-over between the endpoints.
So if e. g. PRO1 has a problem, please use the PRO2 endpoint. Of course, normally all endpoints are up. And we guarantee that there is always one fast, working endpoint available (or money back).
How to create API failover between endpoints?:
Answer: As PRO OCR API user you have access to geographically different endpoints in datacenter1 and datacenter2. The proposed methods help to find the fastest one automatically and avoid any downtime.
Solution 1: Make a call to a GET endpoint with a timeout of e. g. 5 seconds. If you get a response back, the endpoint is up. If not, skip to the next PRO endpoint.
Solution 2: What we do in our UI.Vision RPA software with screen scraping and free Copyfish OCR software (that both use the OCR API !) is to use the first two OCR request to make a call to each of the two endpoints, and then use the fastest one of the PRO endpoints for all future OCR requests. The reason we do this is because the fastest PRO endpoint is different for each user, depending on her or his location.
While the software is making OCR conversion calls, we control the response time and should one endpoint become too slow or even timeout, the software switches to another one automatically.
To explain the source code a bit more, the endpoint switching algorithm works this way:
- Make an API call with e. g. a 30 second timeout
- All works ok: Log response time (to compare later with other endpoints, to find the fastest one)
- No response after 30 seconds: Mark the endpoint as down, and use another endpoint for the OCR conversion.
- After a certain time e. g. one hour, reset all performance values, so that slow or down endpoints have a chance again.
With this algorithm and the multiple OCR.space PRO endpoints we had a 100% uptime in the last three+ years with hundreds of thousands of users. We have 500,000+ users alone for our Copyfish free OCR software .
Of course, other methods to switch between endpoints can work equally well. The import part is that your code automatically switches to another endpoint if one is down or too slow.