Question

I am implementing a comet using AsyncHttpHandlers in my current asp.net application. According to my implementation client initially sends Notification Hook request to server (with its user id) on AsyncHttpHandler, and on server side I maintain a Global (Application level) dictionary of userid(key) and IAynsResult (value). So when ever a request is received to send notification to a user I just pick the matching IAsyncResult from the Global Dictionary and send response to the client user.

My concern is, is maintaing a Dictionary of Userid and IAsyncResult at Application level a good design? I feel it will put a lot of load on the server, at the time of high traffic. Is there any other way I can achieve the comet. or what will be the good design to achieve comet for high traffic scenarios.

Était-ce utile?

La solution

That depends on the number of requests to the server, IAsyncResult request utilizes the process's ThreadPool which automatically manages the number of worker threads. These threads are assigned a task, run them to completion, then are returned to the ThreadPool for reuse.

The ThreadPool is used by other aspects of .NET, and provides a limited number of threads. If you overuse it, there is the possibility your tasks will be blocked waiting for others to complete!

So basically, running a comet server on an ASP.net needs either a strong hardware, or application distribution over several servers.

I would recommend HTML5 WebSocket, which is the W3C API for implementing sockets in HTML and is easier to setup on an ASP.net server:

SignalR for .net 4

ASP.net WebSocket API for .net 4.5

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top