comet

How can I scale socket.io?

不羁的心 提交于 2019-11-28 17:54:43
Let's say a server gets 10,000 concurrent connections (via socket.io). That's a lot, and if it can't handle any more, I need to spin up another server. How can I sync the two servers together with their socket.io? You can try to use for example cluster module and distribute the load to multiple cores (in case you have a multi-core CPU). In case this is not enough you can try to use reverse proxy for distributing requests across multiple servers and redis as a central session data store (if it's possible for your scenario). I wouldn't use Cluster to scale Socket.IO. Socket.IO 0.6 is designed as

Chrome's loading indicator keeps spinning during XMLHttpRequest

扶醉桌前 提交于 2019-11-28 17:29:13
I'm writing an AJAX web app that uses Comet/Long Polling to keep the web page up to date, and I noticed in Chrome, it treats the page as if it's always loading (icon for the tab keeps spinning). I thought this was normal for Google Chrome + Ajax because even Google Wave had this behaviour. Well today I noticed that Google Wave no longer keeps the loading icon spinning, anyone know how they fixed this? Here's my ajax call code var xmlHttpReq = false; // Mozilla/Safari if (window.XMLHttpRequest) { xmlHttpReq = new XMLHttpRequest(); } // IE else if (window.ActiveXObject) { xmlHttpReq = new

Comet OJ - Contest #9 & X Round 3B

為{幸葍}努か 提交于 2019-11-28 17:22:29
Comet OJ - Contest #9 & X Round 3B 其实这个题我一开始,完全⑧会. 题目里给了个关于素数的定理,就考虑一下素数在这题里扮演什么样的角色. 然后你发现,如果他第 \(0\) 天告诉了一个素数,那么只需要一天所有人就都知道了. 如果是一个合数,那么第一天所有素数会知道消息,第二天所有人就都知道了. 需要注意的是,要考虑它第 \(0\) 天告诉一个素数时,如果这个素数的倍数也在这个区间内,是需要两天的. \(Code:\) #include <algorithm> #include <iostream> #include <cstdlib> #include <cstring> #include <cstdio> #include <string> #include <vector> #include <queue> #include <cmath> #include <ctime> #include <map> #include <set> #define MEM(x,y) memset ( x , y , sizeof ( x ) ) #define rep(i,a,b) for (int i = a ; i <= b ; ++ i) #define per(i,a,b) for (int i = a ; i >= b ; -- i) #define

how to combine django plus gevent the basics?

蹲街弑〆低调 提交于 2019-11-28 17:11:42
问题 After much searching and googling I am coming back to the well. I have Django 1.4 and am looking for a decent working example to figure out getting Django to work with gevent. I like the Django framwork but I need it to handle long polling. I already have a working server using gevent on it's own that handles long polling requests as well as does image streaming via http at about 10 frames/second. I would like to use all the goodies in Django to provide a framework for this part. There are

How is GMail Chat able to make AJAX requests without client interaction?

我是研究僧i 提交于 2019-11-28 15:14:50
All HTTP responses require the client to initiate them, even those made using AJAX. But GMail's chat feature is able to receive messages from other users, even when I'm just sitting in my comfy computer chair watching but not interacting with the browser. How did they do it? Pablo Fernandez That tech is known as "comet", but also as "server push", "reverse ajax", etc. It's about pushing data from the server to the browser, keeping an http connection alive. Find more info on it on the wikipedia article ( English version ). Also here's a pretty good presentation with Joe Walker from DWR, where

My Understanding of HTTP Polling, Long Polling, HTTP Streaming and WebSockets

笑着哭i 提交于 2019-11-28 14:56:12
I have read many posts on SO and the web regarding the keywords in my question title and learned a lot from them. Some of the questions I read are related to specific implementation challenges while others focus on general concepts. I just want to make sure I understood all of the concepts and the reasoning why technology X was invented over technology Y and so on. So here goes: Http Polling: Basically AJAX, using XmlHttpRequest. Http Long Polling: AJAX but the server holds on to the response unless the server has an update, as soon as the server has an update, it sends it and then the client

PHP中Push(推送)技术的探讨

余生长醉 提交于 2019-11-28 14:28:29
随着人们对Web即时应用需求的不断上升,Server Push(推送)技术在聊天、消息提醒尤其是社交网络等方面开始兴起,成为实时应用的数据流核心。这篇日志试图探讨的便是各种适合于PHP的Push的实现方式以及其优劣。 1. 什么是Server Push 想象在聊天应用中,如果使用传统的ajax来承担消息的传入,那么一般是通过每隔一定时间拉取一次信息的方式实现,但是其实这种方式有大量查询是浪费的。聊天等Web应用更需要服务器在特定时间来主动告知前端有新的消息( Push ),而不是前端每时每刻问服务器:“来消息了吗?”( Pull )。这也正是为什么这个技术常被叫做反向ajax。 其他别名: Comet ,反向Ajax 2. 如何实现Push 其实所谓的推送技术也没有多么复杂,目前从大类上有3种,一种仍然建立在ajax基础上,还有一种建立在框架基础上,最后一种抛弃了传统的HTTP协议,使用Flash或者HTML5的WebSockets技术。接下来将对这三种类别产生的不同的方式进行探讨。 1) Ajax 长轮询 Ajax长轮询从本质上来说仍然是一种pull,但是实时性较高,无用请求减少很多,是一种不错的Push实现方案。不过它只减少了网络上的无谓消耗。 核心: 客户端发起一个ajax请求,服务端将请求搁置(pending)或者说挂起,直到到了超时时间(timeout)或需要推送时返回

Is there an alternative of ajax that does not require polling without server side modifications?

 ̄綄美尐妖づ 提交于 2019-11-28 13:23:13
I'm trying to create a small and basic "ajax" based multiplayer game. Coordinates of objects are being given by a PHP "handler". This handler.php file is being polled every 200MS, by using ajax. Since there is no need to poll when nothing happens, I wonder, is there something that could do the same thing without frequent polling? Eg. Comet, though I heard that you need to configure server side applications for Comet. It's a shared webserver, so I can't do that. Maybe prevent the handler.php file from even returning a response if nothing has to be changed at the client, is that possible? Then

Timeout behavior of different browsers?

谁说我不能喝 提交于 2019-11-28 11:29:47
I am writing an on line chat room based on AJAX/COMET. My design is: Request ----------------- wait -------------------------> send dump data ----------------- wait -------------------------> send dump data ----------------- wait -------------------------> send dump data ----------------- wait -------------------------> send dump data ----------------- wait -------------------------> send dump data ------ something happened, get response. Another request ..... .... As you see, the server hold the request and wait something happened, if there is some event happened, just push data and finish

前端随心记---------Ajax,Comet,Websocket

浪子不回头ぞ 提交于 2019-11-28 10:34:17
从WebScoket中我们了解到Ajax的轮询问题,WebScoket协议中服务器和客户端只要进行一次握手,就能创建一条通道实现数据的相互传送。而Ajax轮询,在特定的时间间隔内向服务器发送请求,以达到对数据的推送,这样导致浪费了很多无谓的网络带宽,因此产生疑问:为了达到高效且资源利用最大化的角度,WebScoket为什么没有淘汰定时轮询这种机制呢? 什么是Websocket   Websocket是HTML5中提出的新的 协议 ,注意,这里是协议,可以实现客户端与服务器端的通信,实现服务器的 推送 功能。    websocket出现之前,开发者使用轮询 (Polling) 和 Comet 技术。   轮询 :客户端以一定的时间间隔向服务端发出请求,以频繁请求的方式来保持客户端和服务器端的同步。   缺点:当客户端以固定频率向 服务器发起请求的时候,服务器端的数据可能并没有更新,这样会带来很多无谓的网络传输,所以这是一种非常低效的实时方案。   Comet--- 一种 hack 技术, :基于 HTTP 长连接的“服务器推”技术     以即时通信为代表的web应用程序对数据的Low Latency要求,传统的基于轮询的方式已经无法满足,而且也会带来不好的用户体验。于是一种基于http长连接的“服务器推”技术便被hack出来。这种技术被命名为 Comet ,这个术语由Dojo