views:

142

answers:

4

I'm running a PHP front end to an application that does a lot of work with data and uses Cassandra as a data store.

However I know PHP will not give me the performance I need for some of the calculations (as well as the management for the sheer amount of data that needs to be in memory)

I'd like to write the backed stuff in C++ and access it from the PHP application. I'm trying to figure out the best way to interface the two.

Some options I've looked at:

  1. Thrift (A natural choice since I'm already using it for Cassandra)
  2. Google's Protocol Buffers
  3. gSOAP
  4. Apache Axis

The above are only things I looked at, I'm not limiting myself.

The data being transferred to the PHP application is very small, so streaming is not required. Only results of calculations are transferred.

What do you guys think?

+2  A: 

Are you limiting yourself to having C++ as a separate application? Have you considered interfacing it with the PHP directly? (i.e. link a C++ extension into your PHP application).

I'm not saying the second approach is necessarily better than the first, but you should consider it anyway, because it offers some different tradeoff choices. For example, the latency of passing stuff between the PHP and C++ would surely be higher when the two are separate applications than when they're the same application dynamically linked.

Eli Bendersky
I have considered adding it with SWIG, but I think it makes more sense for me to just grab the data out of Cassandra over thrift to my C++ app, do the computation and query the result from PHP.
Stephen Holiday
@Stephen: ultimately it's your choice of course, I just wanted to highlight that this is also a valid path to take
Eli Bendersky
+1  A: 

More details about how much data your computations will need would be useful. Thrift does seem like a reasonable choice. You could use it between PHP, your computation node, and the Cassandra backend. If your result is small, your RPC transport between PHP and the computation node won't make too much difference.

Joshua Martell
A: 

I don't know exactly... but you can call your your C++ function from JavaScript using activeX Control and ATL...

May be this can help..

http://stackoverflow.com/questions/3747414/calling-c-function-from-javascript-script-running-in-a-web-browser-control

mihirpmehta
+3  A: 

If I were you I'd use thrift, no sense pulling in another RPC framework. Go with what you have and already know. Thrift makes it so easy (so does google protocol buffers, but you don't really need two different mechanisms)

codeboy2k