本文介绍了Ajax推送引擎(APE)与Node.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑为我的Web应用程序将数据从服务器实时推送到客户端的几种选择.

I am considering few options for pushing data from server to the client for my web application in real time.

我已经实现了一个基于轮询的应用程序(每个客户端每30秒就会向服务器发送http请求.)该应用程序在10个用户加入后实际上并没有扩大规模.是使用MySQL,PHP,HTML和jQuery构建的.

I have implemented a polling based (each client sends http requests to the server after every 30 secs.) application which really doesn't scale up after 10 users are in. This app. is built using MySQL, PHP, HTML and jQuery.

请考虑以下要求,建议哪个更好-APE Vs node.js

Kindly suggest which one would be better considering the requirements below - APE Vs node.js

  1. 应该一次能够处理至少400个并发连接
  2. 服务器应该能够将数据推送到所有这些客户端.
  3. 客户端之间将跨数据发送.

推荐答案

我强烈建议您看一下 Socket.IO .它是服务器推送的完整解决方案,包括服务器端库(用node.js编写)和以跨浏览器方式制作的客户端JS库.我认为您没有理由实施自己的代码来完成已经完成的工作和测试.

I strongly suggest you to take a look at the Socket.IO. It's a complete solution for server push, that includes both server side library (written in node.js) and client JS library that is made in a cross browser manner. I see no reason for you to implement your own code for doing what is already made, working and tested.

socket.IO无法处理的唯一情况是您的第三个请求,但这是不可能的.如果我理解正确,您希望两个客户端在没有第三方服务器帮助的情况下进行通信吗?您不能将HTTP更改为P2P,至少现在不能.

The only case that socket.IO won't handle is your third request, but that is impossible anyway. If I understand you correctly, you would like two clients to communicate without help of third party server? You can't change HTTP into P2P, at least not now.

另一方面,如果您打算通过服务器与两个用户进行交流(进行像私人两人聊天之类的事情),而这完全可以使用socket.io进行.

If on the other hand you meant to communicate two users via your server (doing something like a private two-person chat) that is totally doable using socket.io.

这篇关于Ajax推送引擎(APE)与Node.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 21:35