Re: validating client in socket communciation
- From: "Peter Duniho" <NpOeStPeAdM@xxxxxxxxxxxxxxxx>
- Date: Mon, 03 Nov 2008 10:39:46 -0800
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
.
- References:
- Re: validating client in socket communciation
- From: Nash
- Re: validating client in socket communciation
- From: Peter Duniho
- Re: validating client in socket communciation
- From: Nash
- Re: validating client in socket communciation
- Prev by Date: Re: How to copy the whole RootElement in an .xml file
- Next by Date: Re: Value type and a parameterless constructor
- Previous by thread: Re: validating client in socket communciation
- Next by thread: Breitling Windrider Chronomat Evolution 18kt Yellow Gold Steel Blue Mens Watch 1335211-C5 Collection
- Index(es):
Relevant Pages
|