Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Photon: high performance PHP/Mongrel2/ZeroMQ micro framework (photon-project.com)
44 points by bpierre on Feb 25, 2011 | hide | past | favorite | 14 comments


If you find this interesting, you might also be interested in DripDrop( https://github.com/andrewvc/dripdrop ), which is an alternate approach to the fusion of ZeroMQ, HTTP, and WebSockets.

It's not a general purpose web server, but targets message passing applications that must move between transports. For instance Browser <-> Web Socket <-> ZMQ is easily possible in it.

It's based on ruby eventmachine (no external daemons needed), and lets you seamlessly pass messages between all three protocols, leveraging the differences of each in interesting ways.

Additionally, it's got tools to help you build isolated components that communicate via messaging only (preferably ZMQ). If you keep this in mind from the start, it can substantially help when it comes to scaling out.

Lastly, we're working on Mongrel2 support as a front end.


I don't know DripDrop (nice name), but messaging is really the way to go. For example with Photon or any system really embracing the message passing approach of Mongrel2, you can get an HTTP request and send back an answer to other connection over jsSocktet (real time analytics for example) or even directly into an HTTP stream (chunked encoding in long polling).

The flexibility to easily address a message to a given connection from everywhere at the backend level is what is wonderful in the protocol developed by Zed.


Well it just so happens that I think ØMQ and Mongrel 2 are to praise here. Yes, having a thin wrapper around Mongrel's backend api helps as well, but you can't compare it to Symfony or Zend unless it's run tested with all features of a regular application. Db, Auth, Sessions etc.

edit: same goes to tests on symfony's site. We've been using Symfony since pre 1.0 days and you'll be lucky to hit 25% of these request rates once you use most of the common features.


However, beneath the benchmarks it does remind the reader that benchmarks are arbitrary.


I have also started a framework called brubeck for using python's eventlet for coroutines for message routing / processing.

https://github.com/j2labs/brubeck

I have the proof of concept, which is more minimal as a project I'm calling mongrevent.

https://github.com/j2labs/mongrevent

Mongrevent has better documentation for how the interaction with Mongrel2 / ZeroMQ works.


For those looking to try this out, be aware that this framework appears to be in a pre-alpha state. Don't expect to download it and expect a working demo without digging into the code and figuring some stuff out on your own.

With that said: Great work on an innovative framework. I applaud the effort so far.


Can I use this stack with Socket.IO in the browser for real-time communication on port 80 to PHP?

In other words, can I implement a simple real-time chat demo using websockets with this stack?


Yes, in 30 lines of code: http://tinyurl.com/chat-server-photon

As Photon is an application server, this means you can do what you do easily with Django/RoR or a Java application server. This breaks the traditional one request, one reply, we forget everything approach of PHP. This is now possible rather nicely as PHP has improved a lot with respect to memory management in the last releases.

Disclaimer, I am the author of Photon and I am locked out of HackerNews with my normal account because of the great anti procrastination mode :-D


Very nice.

Doesn't the Mongrel2 Chat demo use Flash-based socket communication?

I've haven't been able to figure out if Mongrel2 supports native websocket communications on the same port as http traffic (a la nodejs with Socket.IO).


Yes, here this is jsSocket with the little flash stuff to bring socket support to all browsers. WebSocket is coming soon into Mongrel2 (the protocol change delayed a bit the implementation).


Is that the entire script? I do not quite understand how that would comprise an entire project. Could you put it on github, perhaps? I'd like to browse thru a working Photon project.


This is effectively the entire "server side" views handling the jsSocket connection. The front end is a copy/paste of the chat available in the Mongrel2 examples.

I will put up a full tutorial from a bare installation of Debian up to this chat server.


Wasn't Photon the QNX GUI stack?

edit: yes http://www.qnx.com/products/hmi/photon.html


I've been hoping to see more projects using mongrel2.

As ugly and inconsistent as the PHP language is, this project is really cool.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: