使用 C++用于网络应用程序中的后端计算
我正在运行一个应用程序的 PHP 前端,该应用程序对数据进行大量处理并使用 Cassandra 作为数据存储。
但是我知道 PHP 不会为我提供某些计算所需的性能(以及对内存中需要的大量数据的管理)
我想用 C++ 编写支持的内容并访问它来自 PHP 应用程序。我正在尝试找出连接两者的最佳方法。
我看过的一些选项:
- Thrift(一个自然的选择,因为我已经在 Cassandra 中使用它)
- Google 的 Protocol Buffers
- gSOAP
- Apache Axis
以上只是我看过的内容,我并不限制自己。
传输到 PHP 应用程序的数据非常小,因此不需要流式传输。仅传输计算结果。
你们觉得怎么样?
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:
- Thrift (A natural choice since I'm already using it for Cassandra)
- Google's Protocol Buffers
- gSOAP
- 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果我是你,我会使用 thrift,引入另一个 RPC 框架是没有意义的。使用你所拥有的和已经知道的东西。 Thrift 让它变得如此简单(谷歌协议缓冲区也是如此,但你实际上并不需要两种不同的机制)
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)
您是否限制自己将 C++ 作为单独的应用程序?您是否考虑过直接与 PHP 连接? (即将 C++ 扩展链接到您的 PHP 应用程序中)。
我并不是说第二种方法一定比第一种更好,但无论如何您都应该考虑它,因为它提供了一些不同的权衡选择。例如,当 PHP 和 C++ 是单独的应用程序时,在 PHP 和 C++ 之间传递内容的延迟肯定会比它们是动态链接的同一应用程序时更高。
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.
有关计算需要多少数据的更多详细信息将会很有用。节俭似乎确实是一个合理的选择。您可以在 PHP、计算节点和 Cassandra 后端之间使用它。如果结果很小,PHP 和计算节点之间的 RPC 传输不会产生太大差异。
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.