On Wed, 27 Feb 2013 20:47:07 -0500, Arne Vajhøj wrote:
> On 2/26/2013 10:57 PM, Peter Duniho wrote:
>> On Tue, 26 Feb 2013 21:42:55 -0500, Arne Vajhøj wrote:
>>
>>> [...]
>>> 5001- clients : switch to UDP
>>
>> I'm skeptical that this is a good idea.
>>
>> The only person I know personally first-hand who has written a large-scale
>> server architecture from scratch in .NET, he supports hundreds of thousands
>> of simultaneous clients with TCP using the async APIs (the first version).
>
> There are plenty of examples using UDP out there. Documented examples.
That's not the point. I never said one couldn't do it using UDP.
The point is that there are examples of TCP servers that work just fine
with just as many simultaneous connections.
>> UDP won't decrease network overhead. It probably will even increase it.
>
> It will decrease network overhead. But that was not the point.
There's no reason to believe UDP will decrease network overhead. Note that
by "overhead" I am referring to the cost of the network i/o relative to the
whole program (server). UDP itself may have less overhead for a given
amount of data (depending on usage patterns), but the same basic amount of
information (including data to identify the connection being handled) will
still need to move across the network, costing the server the same basic
overhead in network i/o.
>> for sure _will_ increase code complexity, along with design,
>> implementation, and maintenance costs.
>
> It uses the same event driven model as TCP without a thread per
> connection, so no change for that part.
???
TCP does not require a thread per connection. In fact, as has already been
made clear, the key to scalability on Windows is to use the I/O completion
port model, which is specifically about a small number of threads handling
a very large number of i/o operations.
> Some reliability features missing in UDP may need to be added, but
> that will be rather trivial compared to all the other challenges
> in a solution of that magnitude.
Writing a reliable implementation on top of UDP is not trivial at all. Lots
of programmers over the years have gotten, and will continue to get, it
wrong.
> [...]
>> UDP is good for certain things. But I'm aware of no valid evidence to
>> suggest it's the right approach for increasing the number of clients a
>> server can support.
>
> ????
>
> Getting rid of the connection concept do avoid problems with max
> connections rather effectively.
No. First, you are talking about solving a problem that does not exist. TCP
can handle way more than 5000 concurrent connections.
In any case, it simply shifts the cost from the network stack to the
program itself. If the program is going to depend on a connection-oriented
paradigm, that paradigm has to be implemented somewhere.
You can either let TCP handle it for you, or you can do it yourself. But it
has to live somewhere.
The bottom line is that existing TCP-based servers handle far greater
numbers of simultaneous connections than the 5000 you suggest for UDP.
Beyond that, there's simply no real-world indication that UDP is needed to
go beyond that 5000 threshold you suggest, nor is UDP an appropriate
solution when reliable delivery of data is needed.
Reliability in the network i/o is arguably as mission-critical as security,
and just as in the security world, it's foolish to try to reinvent the
wheel. Use the APIs that exist and are appropriate to your needs.
Show me a person who used UDP to get past 5000 concurrent connections in
their server, and I'll show you a person who just didn't bother to learn
how to implement the TCP version correctly.
Pete
(It's also worth pointing out that the real bottlenecks are likely not to
be in the network stack per se, but rather in the server's own logic in
handling clients, and in the network connection itself in supporting the
throughput requested. Handling more than 5000 clients is likely to be
highly dependent on the exact nature of the server's job, and the frequency
of the interactions with each client. But again, TCP itself is well up to
the job, regardless).