长轮询选项:Nginx,PHP,Node.js [英] Long Polling Options: Nginx, PHP, Node.js

查看:96
本文介绍了长轮询选项:Nginx,PHP,Node.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设计一个长时间轮询的应用程序,以非常快的速度向可能的大量用户广播较小的更改.该应用程序将与运行相当标准的cms的网站一起运行.它们都将在一台服务器上运行,并且首先数据库也将运行.

我非常来自LAMP环境,我绝对是一名开发人员,而不是系统管理员.也就是说,我不害怕尝试一些新事物.

我花了一整天的时间研究自己的选择,希望人们能够回答一些问题并给我一些建议.

我将范围缩小到这些:

    A. Apache and php for the website, Node.js for the app
    B. Nginx and php for both the website and app
    C. Nginx and php for website, Nginx and Node.js for the app

所以问题:

  1. Nginx如何处理PHP的非多线程性;). PHP是否会证明与Apache进行长期轮询一样多的瓶颈?
  2. 我听说它建议我将nginx用作Apache和Node.js之前的反向代理,这是否比nginx更好的解决方案?如果是这样,为什么?
  3. 您使用过/建议使用哪个选项?

请记住,易于设置可能是一个因素,我对Apache相当满意,但是我只与Node一起玩,并且从未安装Nginx.

如果有人需要,我会很乐意提供澄清.

解决方案

我将使用选项C :,并建议使用选项D:

选项D:

  • 通过HAProxy保持负载平衡(LB)
  • Nginx用于静态和PHP脚本,使用PHP-FPM,APC和Redis进行缓存
  • 用于动态实时内容的Node.js(和其他Node模块)

我们当前使用选项D的前两个部分,它们来自LAMP背景,并且当前正在实现Node.js,以为我们的某些(系统负担)实时应用提供服务. HAProxy正是这样做的:将流量代理到我所有的后端服务器,而不是让Nginx进行.这样做的原因是,我们有许多后端HTTP/TCP/其他服务器,并且我们需要对这些服务器进行冗余和自动故障转移. LB易于实现且效果很好.

到目前为止,效果非常好.就个人而言,由于缺乏文档,到目前为止,Nodes的学习曲线一直很困难,但是那里有一个非常活跃的社区.

希望这会有所帮助.

I'm designing a long-polling app to broadcast small changes very rapidly to, possibly, a large number of users. The app will run in tandem with a website running a fairly standard cms. They'll both be running on one server, and to begin with so will the database.

I come very much from a LAMP environment and I'm definitely a developer and not a sys-admin. That said I'm not afraid to try out some new things.

I've spent the day researching my options and I'm hoping people can answer some questions and give me some recommendations.

I have narrowed it down to these:

    A. Apache and php for the website, Node.js for the app
    B. Nginx and php for both the website and app
    C. Nginx and php for website, Nginx and Node.js for the app

So the questions:

  1. How does Nginx handle PHP's non-multi-threadingness ;). Will PHP prove as much a bottleneck as Apache would have for long polling?
  2. I've heard it suggested that I use nginx as a reverse proxy in front of Apache and Node.js, is that a better solution than just nginx? If so, why?
  3. Which option have you used/would recommend?

Bear in mind that ease of set-up could be a factor, I'm fairly comfortable with Apache but I've only played with Node and I've never installed Nginx.

I'll happily provide clarifications if anyone needs them.

解决方案

I would use option C: and would suggest an option D:

option D:

  • Keepalived with HAProxy for load balancing (LB)
  • Nginx for static and PHP scripts, using PHP-FPM, APC and Redis for caching
  • Node.js (and other Node modules) for dynamic, realtime content

We currently use the first 2 parts of option D, coming from a LAMP background, and are currently implementing Node.js to serve some of our (system taxing) realtime apps. HAProxy does exactly that: proxies the traffic to all my backend servers, instead of having Nginx doing it. Reason for that, we have many backend HTTP/TCP/other servers and we require redundant and automatic failover to these servers. LB is simple to implement and works well.

So far, excellent results. Personally, the Nodes learning curve has so far has been difficult due to lack of documentation, but there is a very dynamic community out there.

Hope this helps.

这篇关于长轮询选项:Nginx,PHP,Node.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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