开发者

How many WCF connections can a single host handle?

I'll try to explain this with an example. I'm writing a chat application. There are users that can join chat rooms. A user has to log in before he can join any room.

Currently, there is a single service. A user logs in using this service. Then, the user sends and receives messages for all joined rooms via this single service.

channel.Login("Hans Moleman", "password");
channel.JoinRoom("name of room");
channel.SendChat("name of room", "hello");

I'm thinking about changing the desi开发者_C百科gn so there is a new WCF connection for each joined room. In the actual app, the number of connections is likely going to be in the range of 10-100, possibly more.

Is this a good idea? Or are ~100 connections per client too much? The server should be able to handle many clients (range 100-1000, later up to 10k). In case it matters, I'm using NetTcpBinding.


From a practical standpoint, WCF will let you have as many connections as you want. You can set a maximum number by using a Service behavior. I believe there is a limit, but it's VERY high (higher than you would likely want or need on a single server)

Aside from the WCF issue, there are other things to consider:

When you do this you also need to take into consideration how you are going to thread your service and handle concurrency if need be.

There is also a hardware issue. Can the box you're putting this server on not only handle the load of 100 instances of your service running, can your network deal with traffic? What kind of throughput are you looking for?

So in summary, WCF will allow you to have as many connections as your hardware and network will support.


The question is never as simple as "how many connections are too much," because such things always depend on what the connection is doing. If it's a chat application, I could imagine that mostly the connection will be idle. In that case, you could handle a lot more connections than, say, a file uploader that's using maximum bandwidth constantly.

But, to ask you the question you should really be thinking: what do you gain out of having multiple connections? Each connection represents overhead both to client and server, and you'd have to authenticate individually for each connection. That's a lot of overhead to an otherwise low-bandwidth connection.

Also, maintaining up to 100 connections per client at the server end might be a much more significant factor to consider.

Obviously I have no idea about your system/architecture, but from your description so far I would say that it's not a good idea.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜