English 中文(简体)
Web Sockets - server load
原标题:

I m trying to learn new technology called Web Sockets. I ve got the setup (pywebsocket as Apache2 module) working and I m playing with examples. http://code.google.com/p/websocket-sample/wiki/samples?ts=1262888726&updated=samples

One thing is bothering me - all the examples use shared file to monitor changes in message counter, counter of users.

So basically when I connect to ws://localhost/chat with 2 browsers 2 instances of chat_wsh.py (websock handlers) will be running. Right? And they all will be accessing file/database for count.

It might be a silly question, but I m not a network guru - is it possible to broadcast a message to all connections from one handler.

For example: User from chat sends a message - message through websocket gets to websocket handler which in turn broadcasts info that new message is received to all other chat instances, eliminating thus the need for each instance to constantly check on one shared file/database.

I hope I make sense :)

最佳回答

I think you are trying to describe UDP Multicast.

See this link for more info Multicast

Unfortunately Websockets work over TCP which are as you have discovered for one-to-one connections.

You can look into somthing like memcached http://memcached.org/ to make it "low overhead" to keep a shared state of the chatroom

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签