There are two processes running in the server (LINUX), they are PHPApp and C++App. The PHPApp is written by PHP and C++App is written by C++.
Now they need to communicate with each other to perform below task: PHPApp sends a request to C++App, when the C++App receives the request it reads data from shared memory and does some calculation, finally return the data to PHPApp.
There are two methods to do above:
- PHPApp communicates with C++App by sockets. C++App will serve as daemon process.
- PHPApp communicates with C++App by calling exec(...) (php has such function). No C++App process until there is request from PHPApp, and in this way each request requires one C++App instance.
I wonder which way is more efficient?
UPDATE
The PHPApp is part of a server software based on Apache, thus there might be hundreds of PHPApp processes sending requests to C++App. The PHPApp makes request in parallel.