简体   繁体   English

Websocket服务器该选择哪个?

[英]Websocket server which to choose?

I am developing a big PHP application in ZF2, and I need real-time interaction in this app, so websocket are my choose. 我正在ZF2中开发一个大型PHP应用程序,并且需要在此应用程序中进行实时交互,因此我选择了websocket。 I have PHP, Mysql, Memcached. 我有PHP,Mysql,Memcached。 I need a websocket server. 我需要一个websocket服务器。 What would be the best choise. 最好的选择是什么。 Requiments of my websocket server: 我的websocket服务器的要求:

  • support mysql, memcached and maybe gearman 支持mysql,memcached甚至Gearman
  • Support https connections, very important 支持https连接,非常重要
  • optionally support IE (but this is not important if loose benefits) (可选)支持IE(但如果没有好处,这并不重要)
  • scalable 可扩展性

My problem is choosing from a PHP (wrench) websocket server or a based Node.js(socket.io) server. 我的问题是从PHP(扳手)websocket服务器或基于Node.js(socket.io)的服务器中选择。 Which should I choose? 我应该选择哪一个?

If I use the PHP one I can use PHP code and ZF2 function, so easy to develop, but I do not have non-html5 browser support (do I have ssl support here?) 如果我使用的是PHP,那么我可以使用PHP代码和ZF2函数,因此很容易开发,但是我没有非HTML5浏览器支持(我在这里有ssl支持吗?)

If I use socket.io I have all browser support and fallback, but here I need to re-write all function (in js) to work with mysql, memcached and so on... 如果我使用socket.io,我将拥有所有浏览器支持和后备功能,但是在这里,我需要重新编写所有功能(在js中)以使用mysql,memcached等。

WaterSpout Server claims to offer WebSocket or Long-Polling connections: https://github.com/chrisnetonline/WaterSpout-Server WaterSpout Server声称提供WebSocket或长轮询连接: https : //github.com/chrisnetonline/WaterSpout-Server

So this may be a solution that works in all browsers. 因此,这可能是适用于所有浏览器的解决方案。

All solutions are scalable. 所有解决方案都是可扩展的。 The questions are really; 问题是真的; how soon do you want to have to start thinking about scaling? 您想多久开始考虑扩展? When do you want to scale vertically and add additional resource to your server? 您何时要垂直扩展并向服务器添加其他资源? When do you want to add another server (scale horizontally) and deal with synchronisation connection and state information between those servers? 您何时要添加另一台服务器(水平缩放)并处理这些服务器之间的同步连接和状态信息? IMHO you'll be doing this sooner with a PHP solution. 恕我直言,您将通过PHP解决方案更快地做到这一点。

If you mainly want to write code in PHP and you would prefer to keep things simple then I'd recommend you use a hosted realtime service as part of your application stack. 如果您主要想用PHP编写代码,并且希望保持简单,那么我建议您使用托管的实时服务作为应用程序堆栈的一部分。

Some relevant posts ( which I wrote ): 一些相关的帖子( 我写过 ):

I'd recommend Node.js, because PHP is not the best solution for applications, which have to stay in memory for a long time (PHP leaks memory). 我建议使用Node.js,因为PHP并不是应用程序的最佳解决方案,因为它们必须在内存中保留很长时间(PHP会泄漏内存)。

http://software-gunslinger.tumblr.com/post/47131406821/php-is-meant-to-die http://software-gunslinger.tumblr.com/post/47131406821/php-is-meant-to-die

I'm sure there are lots of reusable Node modules for you not to reinvent a bycicle. 我确定有很多可重复使用的Node模块供您使用,以免重新发明自行车。

Of course, if it works for you, you can use some PHP-powered daemon and restart it once in a while to control it's stability to some extent. 当然,如果它适合您,则可以使用一些PHP驱动的守护程序,并不时地重新启动它,以在某种程度上控制其稳定性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM