Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 May : Re: I/O competion ports in Indy?

www.cryer.info
Managed Newsgroup Archive

Re: I/O competion ports in Indy?

Subject:Re: I/O competion ports in Indy?
Posted by:"Piotr Szturmaj" (gacek999@nospam.tlen.pl)
Date:Wed, 24 May 2006 17:55:30

>> -In general: If IOCP works can it support 100.000+ connections on a
>> single
> windows box?

Microsoft claims that it can

> No.  64k sockets are all that is available on any box.  W2k Pro will
> stagger
> up to about 25k sockets, (providing that the load per socket is low, of
> course:).  Server versions may do better.

Yes, you can have maximum 64k sockets on single domain, but you can also
have few domains (few IP's). The worst thing is amount of non-paged memory
(non-paged pool), where socket's data resides. Assuming single socket uses 4
KB of memory there's about 200 MB needed to serve 50,000 sockets. Commonly
non-paged pool size is equal to quarter of amount of physical RAM, so
theoretically you can have 512 MB pool with 2GB RAM on 32 bit Windows (or
768 MB with 3GB address space - special boot switch needed). Too bad Windows
2000 have upper limit set to 256 MB, I dont remember what are limits on
newer Microsoft OS's, but since 64 bit Windows provides few terabytes of
address space limits should be higher.

>> -I am building a chatserver which has to support as many clients
>> as possible per box, but the TCP connections don't have to do a
>> lot, just when people send chatrequests.
>> It is very tempting to try it in UDP because that means
>> unlimited "connections".

UDP is "connection-less" protocol, in opposite to TCP "stream" it uses
"packets" (datagrams) to communicate with others. UDP dont provide reliable
data delivery like TCP do, you must manually handle packet losing,
disordering, resending dropped packets etc. In addition you can send only
about 8 KB packet at maximum, so you must consider dividing your payload
between UDP datagrams.

> 'Chat' is a TCP protocol, AFAIK.

Indeed, TCP is often used when creating 'chat' applications, but since
simple chat protocol rarely issue small amount of (text) data I'd bet on UDP
and say that TCP adds too much overhead when supporting hundrens of
thousands of clients.

> Or would I be building checks (and keep
>> alive packets every minute) to see if messages arrived and just
>> reinventing TCP all over again no matter how I solve it? I know this is
> the usual answer but in this case it would be nice to avoid the IOCP mess.
>
> IOCP and/or overlapped I/O is not trivial, surely, but is certainly
> possible
> with Delphi.  I have had the max. 24/25 k connections open with W2k Pro
> without too much of a problem.

Now it is not a big deal for me, since I understand how it works. Indeed,
it's not trivial for beginner, trying to figure what is what when
documentation is poor and examples (if any) are hard to understand.

regards
Piotr Szturmaj

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive