Re: validating client in socket communciation



On Mon, 03 Nov 2008 02:40:12 -0800, Nash <jeevs007@xxxxxxxxx> wrote:

I have another question in sockets. my requirement is like a server
that can handle 1 million clients. is it possible to have 1 million
sockets kept open through out or shall the client open the connection
whenever it needs to send data and close it, will there be any
overhead in this process than keeping the connection open forever?

There certainly is significant overhead for each socket that you keep open. But, performance-wise there is even more overhead opening and closing connections between the server and the same client over and over. Unless clients only communicate with the server very infrequently, you should just keep their connections open.

That said, a server supporting 1 million sockets is going to have to get _everything_ right. Even at hundreds of thousands of sockets, only by being very careful about your code can you achieve acceptable throughput. For 1 million, on top of coding everything perfectly, you'll need a computer with lots of i/o bandwidth, lots of CPUs, a huge amount of memory, and a way to service each client i/o operation extremely quickly.

Just being able to keep the sockets open is only a small part of the battle. Note, of course, that unless you maintain very tiny buffers (which will be terrible for performance), you're going to need 64-bit Windows to support that many sockets. (Actually, you might need that many anyway...I don't have first-hand experience implementing something that large, so can't say for sure it'd work for you under any circumstances on 32-bit Windows).

If you want to scale up that large on a single server, you should definitely be looking at the newest Socket APIs for asynchronous i/o. That is, the methods ending in the word "Async". These are even more efficient than the previous async methods (methods starting with the word "Begin"), and I believe that you have no hope of supporting 1 million simultaneous clients without them, not in .NET anyway.

That's all assuming you can get it to work at that scale at all. I've only heard of servers at that scale in shops where experts at network i/o are doing the programming; it's not for the faint of heart, that's for sure. :)

Pete
.



Relevant Pages

  • Socket communication on multihomed box
    ... I'm building a kind of server which is supposed to handle ... The thing is that connection MUST always stay open. ... as for sockets, I'm using native syscalls, not MFC. ... Another thing is that is should work both under Linux and Windows. ...
    (microsoft.public.win32.programmer.networks)
  • Socket communication on multihomed box
    ... I'm building a kind of server which is supposed to handle ... The thing is that connection MUST always stay open. ... as for sockets, I'm using native syscalls, not MFC. ... Another thing is that is should work both under Linux and Windows. ...
    (comp.programming)
  • Re: Problem with a Socket server program opening/accepting many connections and the GC is running.
    ... I'm not quite sure what you mean by "slowed down my server by adding a 10ms ... to handle the connection as quickly as possible? ... other clients requests are being serviced. ... >> available sockets. ...
    (microsoft.public.dotnet.framework.performance)
  • Re: Storing data from multiple clients
    ... The .NET Connection classes can not be used by multiple trheads. ... Opening a connection will reuse the connection on the SQL Server side if possible, so the SQL Server will create it only once. ... You could collect lets say 10 messages from the clients and send them as a bunch to a stored procedure on the database server. ... Try to decouple the insert from the TCP sockets, because you never know, how much time it will take. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Ideas required for usage of sockets API for efficient network programs
    ... I am evaluating various methods of using sockets API for a network ... The server reads data from clients and writes data to clients. ...
    (comp.os.linux.development.apps)