在没有http的同一服务器上从php发送信息到ngnix [英] Sending information to a ngnix from php on the same server without http

查看:163
本文介绍了在没有http的同一服务器上从php发送信息到ngnix的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在开发一个实时应用程序,我们正在为websockets部分使用nginx推流模块。首先,数据从客户端发送到一个php脚本,它执行一些认证,并在数据库中存储所需的信息,然后将信息推送到nginx,然后将其发送到特定套接字上的订阅用户。通常情况下,会有更多的30个http请求从这个脚本到本地nginx(,我不确定是一件坏事吗?)。

We are developing a realtime app and we are using nginx push stream module for a websockets part. Firstly, data is send from a client to a php script that does some authentication and stores needed information in database and then pushes information to nginx that later sends it to a subscribed users on a specific sockets. Quite often there will be situations when there are more that 30 http requests made from this script to local nginx (which I am not exactly sure is a bad thing?).

问题

是否可以从php向nginx发送信息而不需要http请求?有什么办法,我的php脚本可以与nginx沟通?处理这种通信的最佳做法是什么?每个php脚本发送30+ http请求一个好的做法?

Question
Is it possible to send information from php to nginx without http requests? Is there any way that my php script can communicate with nginx? What is a best practise to handle this kind of communications? Is sending 30+ http requests per php script a good practise?

我已经阅读了一些AMQP解决方案,但没有找到信息,其中nginx是从rabbitmq消息的消费者。

I have read towards some AMQP solutions but haven't found information where nginx is a consumer of messages from rabbitmq.

如果不清楚,我会很乐意提供任何其他信息。

I will gladly provide any additional information if something is not clear.

推荐答案

我假设如下:

当前工作流程


  1. 用户从命令行运行php脚本,使用http请求与Nginx中的服务器端脚本/ cgi setup进行通信

  2. 服务器端Nginx中的脚本/ cgi将接收传入的数据,将其处理并将其放入数据库或发送给最终用户。

OP关注:

使用http协议与Nginx服务器端脚本通信的命令行php脚本的效率,这可能是由于通信在同一服务器。

Efficiency of command line php script communicating with Nginx server side script using http protocol, which maybe overkill as the communication happen within the same server.

提案1


  1. 命令行脚本将所有信息写入文件,
    然后向Nginx服务器端cgi脚本发送一个http请求

  2. Nginx服务器cgi脚本,收到请求后,所有
    信息,然后处理

  3. ramfs(ram disk)可以用来最小化物理高速缓存的I / O

提案2

将您的命令行php脚本合并到Nginx服务器端脚本,并为其创建Web界面。

Combine your command line php script into the Nginx server side script, and create a web interface for it. Current command line user will login webpage to control the process they used to do it with command line tool.

Pro:没有更多的脚本之间的脚本可以使用命令行工具/进程间通信。整个工作流程是在一个过程。这可能对未来更具可扩展性,因为多个用户可以通过Web界面登录并远程处理该过程。此外,他们不需要操作系统级别的帐户。

Pro: No more inter-scripts/inter-process communication. The whole work flow is in one process. This maybe more scalable for the future also, as multiple users can log in through web interface and handle the process remotely. Additionally, they do not require OS level accounts.

Con:可能需要更多的开发时间。 (但你只需要维护一个代码基而不是两个。)

Con: May need more development time. (But you only have to maintain one code base instead of two.)

这篇关于在没有http的同一服务器上从php发送信息到ngnix的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆