I have an OCR engine to extract characters from images which was written in Python and I have a restful API server in PHP running on nginx.
I like to receive a image file from the end user on PHP API server and send the image to OCR engine to read letters and get back to PHP server with extracted characters. So I can respond the users with the result.
This should be fast. As for the quality of the service, speed is the one of the most important things in API. So I wonder what is the best way to set up this process.
I've thought about the following solutions:
1. Since OCR engine was written in Python, I should build a Python Flask API server to communicate with PHP API server. In case, I just send a request API call from PHP server to Flask server.
2. I deploy the OCR engine on the same server (PHP API server) and use shell command in PHP to run the OCR engine. In this case, I don't have to keep running OCR engine all the time.
I think that running another API server costs more response time and resources of the machine. So I think deploying OCR engine at the same server is better way than communicating b/w two API server.
Anyhow, I am not quite sure about that.
Which is the best and fastest way to handle this process?
Any advice would be appreciated. Thanks.
What I have tried:
I deployed two servers, php api server and python flask api server which communicate with ocr engine. In this case, php sends a request to flask api server.
Data flow is like this:
User > php > flask > ocr engine
ocr > flask > php > user
It's simple, but it takes time because I have to request another call via network.
So I am thinking to deploy OCR on the php server to get the fastest response from it.