从服务器端应用程序推送消息给客户呢? [英] Pushing messages to clients from a server-side application?

查看:182
本文介绍了从服务器端应用程序推送消息给客户呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于JavaScript的客户端是目前轮询新内容.NET Web服务。虽然投票工作......我不是很满意这种方法,因为我使用的系统资源,并产生额外开销,当有不接受任何更改。

I have a javascript-based client that is currently polling a .NET web service for new content. While polling works...I'm not happy with this approach because I'm using system resources and creating overhead when there aren't any changes to receive.

我的问题是我怎么通知我的客户(S),有新内容等待它出现?我愿意接受任何其他技术我会实现这个解决方案。

推荐答案

首先,投票是要走的路。你可以使用Flash或Silverlight或彗星做到这一点 - http://en.wikipedia.org/wiki/ Comet_(编程),它可以容纳一个TCP连接为你打开的通知。<打击>一个网页本身不能持有一个套接字开放,所以没有办法直接通知Web客户端。

First of all, polling is the way to go. You could do it with Flash or Silverlight or Comet - http://en.wikipedia.org/wiki/Comet_(programming) which can hold a tcp connection open for you for notifications. A webpage itself cannot hold a socket open, so there is no way to directly notify a web client.

<击>不过,仔细想想,有多少客户可以持有对一台服务器在同一时间一个TCP连接?对于一个更大的系统,你将耗尽可用的插座pretty的快,因为有65000端口可用。
多少个并发连接,您的服务器可以处理取决于你的硬件资源。如果你有足够的内存和CPU,你应该能够处理10万〜可能更多。但是,如果每个请求访问数据库或者通过TCP / IP一​​些其它资源,可以被限制在每个IP端口的可用的数量(65000)。你也应该有推请求去对一个单独的域,作为浏览器正常上限,以每个域两个并发连接,这样你就不会与正常的网页加载干扰。

But think about it, how many client can hold a tcp connection towards one server at a time? For a larger system you would run out of available sockets pretty fast as there are 65k ports available.
How many concurrent connections your server can handle depends on your hardware resources. If you have enough memory and cpu you should be able to handle ~100k and maybe more. But if each request access a database or some other resource over tcp/ip, you could be limited to the number of ports per ip available (65k). You should also have the push requests go against a separate domain, as a browser normally caps to two concurrent connections per domain, so you won't interfere with the normal page loading.

在与前面缓存服务器结合使用轮询是一个很好的解决方案。你可以有逻辑,更新每个客户端的缓存,减少负载每个轮询服务器上。你可以更新谁在/轮询在几分钟之内的X个,以减少缓存更新更签署了缓存的用户。而对我实施拉比拉容易,技术明智的。

Using polling in combination with cache servers in the front is a good solution. You can have logic on the server which updates the cache per client, reducing the load for each poll. You could update the cache for users who have signed in/polled within the X number of minutes to reduce the cache updating even more. And to me implementing pull is easier than pull, technology wise.

这篇关于从服务器端应用程序推送消息给客户呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆