Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using WebSocket on Apache server

With all the buzz around WebSockets, it's pretty hard to find a good walkthrough on how to use them with an Apache server on Google.

We're developing a plugin, in PHP (symfony2), which will run from time to time kind of a chat instance. And we find WebSockets more interesting, standard and quick than AJAX for this matter. The thing is, we don't have much sysadmin ressources in our group and we find hard to gather good informations on the following matters:

  • Can we run a WebSocket instance on a traditional Apache, dedicated server, and if yes, do you have useful links for us?
  • If we need to mod the server, what kind of tools would you recommend knowing that we are not too skilled in sysadmin so we can't afford to have a high maintenance b*** on this.

Thank you very much,

ps: we'll link back to your blog/site as we'll make a technical/informational post on our devblog about this part of our app.

Thank you again!

like image 918
Edouard Reinach Avatar asked Jul 04 '12 19:07

Edouard Reinach


1 Answers

As @zaf states you are more likely to find a standalone PHP solution - not something that runs within Apache. That said there is a apache WebSocket module.

However, the fundamental problem is that Apache wasn't built with maintaining many persistent connections in mind. It, along with PHP, is built on the idea that requests are made and responses are quickly sent back. This means that resources can very quickly be used up if you are holding requests open and you're going to need to look into horizontal scaling pretty quickly.

Personally I think you have two options:

  1. Use an alternative realtime web technology solution and communicate between your web application and realtime web infrastructure using queues or short-lived requests (web services).
  2. Off load the handling of persistent connections and scaling of the realtime web infrastructure to a realtime web hosted service. I work for Pusher and we fall into this category.

For both self-hosted and hosted options you can check out my realtime web tech guide.

like image 114
leggetter Avatar answered Sep 27 '22 18:09

leggetter