Using C++ for backend calculations in a web app
Asked Answered
I

3

9

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?

Indoiranian answered 22/9, 2010 at 3:39 Comment(2)
+1 for a good question. I look forward to the answers (btw, I lirk gSoap)Strangle
Thanks, what do you like about gSOAP?Indoiranian
S
1

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.

Sprage answered 16/10, 2010 at 6:27 Comment(0)
K
3

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)

Karajan answered 16/10, 2010 at 7:12 Comment(0)
M
2

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.

Magna answered 22/9, 2010 at 5:26 Comment(2)
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.Indoiranian
@Stephen: ultimately it's your choice of course, I just wanted to highlight that this is also a valid path to takeMagna
S
1

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.

Sprage answered 16/10, 2010 at 6:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.