Board index » delphi » how to develop a scalable winsock server

how to develop a scalable winsock server

Hi,

I need to develop a scalable server which will talk to hundreds of
active clients.

Can windows support this much active clients for a server? What is the
best architecture for the server? Should I use threads or any other
mechanism? Also which component I should use to manage these clients?

Regards,

--

Bahri OKUROGLU

 

Re:how to develop a scalable winsock server


Quote
> Can windows support this much active clients for a server? What is the
> best architecture for the server? Should I use threads or any other
> mechanism? Also which component I should use to manage these clients?

Yes, Windows can handle a couple of thousands of clients at the same time
(at least Win2K). You don't need components. The best solution is pool of
threads and the app written in pure API and HIGHLY optimized. We made a
custom WWW server recently, and the approach of manual optimization shows
that any components (and classes too btw) will slow down the code. Thread
pooling is significant speed improvement too.

--
Eugene Mayevski,
EldoS, chief coordinator
Custom software development for Windows, Palm and WinCE
http://www.eldos.org/outsourcing.html

Re:how to develop a scalable winsock server


Say?n Bahri Bey,

INDY bile?enlerini kullan?rsan?z, bu k{*word*7}havuzlama (thread pooling)
i?lemini destekliyor. Ger?i dokmantasyon biraz zay?f ancak, bu bile?enler
hem a??k kaynak (open source) hem de cretsiz. stelik ortak bir ?ekilde
srekli geli?tirilmekte.

URL : http:/www.nevrona/indy/

Sayg?lar?mla,

ATB

Quote
Bahri Okuroglu wrote:
> Hi,

> I need to develop a scalable server which will talk to hundreds of
> active clients.

> Can windows support this much active clients for a server? What is the
> best architecture for the server? Should I use threads or any other
> mechanism? Also which component I should use to manage these clients?

> Regards,

> --

> Bahri OKUROGLU

Re:how to develop a scalable winsock server


Quote
> > Can windows support this much active clients for a server? What is the
> > best architecture for the server? Should I use threads or any other
> > mechanism? Also which component I should use to manage these clients?

> Yes, Windows can handle a couple of thousands of clients at the same time
> (at least Win2K). You don't need components. The best solution is pool of
> threads and the app written in pure API and HIGHLY optimized. We made a
> custom WWW server recently, and the approach of manual optimization shows
> that any components (and classes too btw) will slow down the code. Thread
> pooling is significant speed improvement too.

Just a notice: the pool of thread should mean that little number of threads
(typically one thread per one CPU if the server has multiple CPUs) serves
big number of simultaneous requests.

If the number of simultaneous requests is relatively low you can write a
simple multithreaded application (one thread per request, threads using
blocking mode winsock sockets). But context switching between the threads
takes some time and when there is big number of threads big portion of CPU
time is consumed by code which switches between the threads. So in the time
you have to use another model - you have to use completion ports (winsocks
2) and one thread (work thread) per one cpu in the server (note: the proper
number of threads per cpu depends on type of your service in some cases).

There are some related articles about completion ports performance on the
msdn.microsoft.com or you can find a description/discussion and examples in
Network Programming for Microsoft Windows book.

Regards
Dalibor Toman

Re:how to develop a scalable winsock server


dto...@fortech.cz (Dalibor Toman) wrote in <3adf3bd8_1@dnews>:

Quote
>blocking mode winsock sockets). But context switching between the threads
>takes some time and when there is big number of threads big portion of CPU
>time is consumed by code which switches between the threads. So in the time

Yes and no - this is a "myth". You should read the "hundreds of threads"
topic in the Intro to Indy article.

--
Chad Z. Hower (Kudzu) - Church Hill, TN - Team Indy
      "Programming is an art form that fights back"
Forget the Y2K problem, Lets fix the W2K problem.
http://www.pbe.com/Kudzu/ - Free Delphi/CBuilder components and articles

Re:how to develop a scalable winsock server


Quote
Eugene Mayevski wrote:
> > Can windows support this much active clients for a server? What is the
> > best architecture for the server? Should I use threads or any other
> > mechanism? Also which component I should use to manage these clients?

> Yes, Windows can handle a couple of thousands of clients at the same time
> (at least Win2K). You don't need components. The best solution is pool of
> threads and the app written in pure API and HIGHLY optimized. We made a
> custom WWW server recently, and the approach of manual optimization shows
> that any components (and classes too btw) will slow down the code. Thread
> pooling is significant speed improvement too.

In this way, it seems that I can only serve to N number of clients
concurrently where N is the number of threads. Is this true?

Should I let one thread to serve M active clients using select()?

--

Bahri OKUROGLU

Re:how to develop a scalable winsock server


bah...@netas.com.tr (Bahri Okuroglu) wrote in
<3ADFEC89.D5CF9...@netas.com.tr>:

Quote
>Should I let one thread to serve M active clients using select()?

It depends on your app. Its a LOT of extra work and in most cases will
obfuscate your code badly.

--
Chad Z. Hower (Kudzu) - Church Hill, TN - Team Indy
      "Programming is an art form that fights back"
Forget the Y2K problem, Lets fix the W2K problem.
http://www.pbe.com/Kudzu/ - Free Delphi/CBuilder components and articles

Other Threads