OCR API PRO Endpoints

Question from a PRO OCR API user: Does my request to your Datacenter #1 endpoint (PRO1) get routed to another endpoint, such as the Datacenter #2 endpoint (PRO2), if the endpoint #1 is too heavily loaded?

I ask because I would like to know If I need to send my request to multiple endpoints from my application, or are your load balancers already doing the same thing during periods of heavy loading?

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).

:point_right: 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 monitor the API response time and should one endpoint become too slow or even timeout, the software switches the other endpoint automatically.

Javascript source code of solution 2 (Copyfish and UI.Vision Core are both open-source): Copyfish/background.js at 1cbce8558c63c55cf79223cf741757835510fe78 · A9T9/Copyfish · GitHub

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 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.

1 Like

What are the URL’s for the two endpoints?

Your PRO endpoint URLs are listed in the email that you received when you subscribed to your PRO or PRO PDF plan. It is the same email that had the api key inside. Important: The PRO endpoints are not the same as the free OCR API endpoint.

If you lost the initial welcome email, no worries. Just email us at team AT ocr.space and mention this forum post.