douan6931 2014-07-16 16:24
浏览 54
已采纳

与PHP守护进程通信的最有效方法是什么? [关闭]

I did some PHP daemon and now I want my PHP webapp to communicate with it, e.g. send XML document to it and receive response after some time. As I would like to avoid file operations over the network (as it involves FTP), what would be the ideal way of sending this document? The PHP daemons and PHP webapps are on different servers. I have investigated various options so far:

  • ActiveMQ, but that adds additional bloatware
  • TCP Sockets (however it's hard to do it as the PHP daemon is single-threaded and very busy sometimes)
  • FTP, SCP to send the file
  • NFS / CIFS
  • Using database

If the messaging server looks like the best option, what would be best suited for PHP? I would like to avoid centralized, single messaging server because it's difficult to approve firewall rules, and the network is very big, complex and very fail-prone. So that would require star-shaped network of messaging servers, and because of that they would need to very lightweight, easy to deploy and with no difficult dependencies.

  • 写回答

2条回答 默认 最新

  • duanbarong4617 2014-07-16 18:04
    关注

    The answer is obvious: Use TCP but don't use a single threaded programming language for a TCP daemon.

    If you want to use PHP for the workers, maybe because you wish them to use a shared PHP library, you can code a most minimal daemon in a programming language which supports threads, and forwards the requests to PHP helper scripts (or pooled, single threaded TCP daeamons if you want to deploy the workers on different hosts, which is good for scalability)

    However, a software which fulfils the requirements exists already: Gearman

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办
  • ¥15 vue2登录调用后端接口如何实现