8 ms·
What nginx needs to become the ultimate platform, in my opinion, is to provide an API for interacting with WebSockets by transient processes (such as PHP). That
by trebor 14y ago
What nginx needs to become the ultimate platform, in my opinion, is to provide an API for interacting with WebSockets by transient processes (such as PHP). That way it acts as a surrogate pub-sub handler, whether or not your instance stays as a running process.
That'd be a dream for what I want to do. At best, we have to use Node.js as a WebSocket provider and tie it in with the PHP sessions, etc. Not as simple as I'd like.
- the_gipsy 14y agoPHP simply is not suited for long lived processes. If you only want the ability to push something to clients without polling, then maybe you could set up something very simple with python, and communicate over redis or some other MQ.
- 0x0 14y agoWhat makes you say that? I've been running several PHP processes for weeks at a time with no problems, feeding on busy TCP connections for the whole time.
- the_gipsy 14y agoI didn't say that you can't do it.
- 0x0 14y agoBut why do you find it unsuitable?
- Shorel 14y agoIt has ugly syntax and bad standard function names, and some people code ugly things with it. /sarcasm
- the_gipsy 14y agoIt is build around a model of process input, spit output, exit; which is not what you want for long living processes. There are many articles about it's flaws, my favourite is this one: http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/ http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-de...
- elliotanderson 14y agoA few years ago I would have agreed, but I have several PHP daemons consuming messages from RabbitMQ and their uptime is in the range of months. Throw a little supervisord into the mix to keep an eye on things and you'd be surprised how far it has come.
- MartinMond 14y agoYou mean like https://github.com/wandenberg/nginx-push-stream-module https://github.com/wandenberg/nginx-push-stream-module? :)
- lux 14y agoRatchet (http://socketo.me/ http://socketo.me/) has started to make this easier. Regardless of the naysaying people will always do about PHP and long-running processes, an Nginx WebSockets proxy/backend protocol would be a huge hit for PHP developers, and as demonstrated by Ratchet, can certainly be made to work just fine.
- jqueryin 14y agoI recently did a presentation on Ratchet with working demos. You can view all of the source code via the github repository: https://github.com/cballou/php-websockets-demos https://github.com/cballou/php-websockets-demos The three demos are of increasing complexity, with the third being a WTF example of adding WebSockets to an existing PHP application (in this case, a basic CRUD todo app).
- lux 14y agoCool, browsing through your demos now!
- trebor 14y agoRatchet does look nice, but has several deployment dependencies and architectural constraints. Hopefully with nginx now adding the features to be a WebSocket proxy you could get HAProxy out of the way (unless you wanted it).
- FooBarWidget 14y agoNow that Nginx supports WebSockets, Phusion Passenger can start supporting WebSockets as well and allowing all hosted apps access to it. Node.js support is experimental, and there are plans to support PHP and other languages as well.