[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework

Robust Server using Sockets

Nash

11/4/2008 4:06:00 AM

Hi,
I want to develop a server application which can handle 1 million
clients. I plan to use asynchronous tcp/ip sockets to handle clients.
The communication is not frequent and the data transfered is also
less(Max 100kb packet)

I have some ideas to implement it

1. To have a single server which will service all the 1 million
clients. Server will listen to the connections on a particular port
and once connected will keep the connection open forever.

2. To have a single server which will service all the 1 million
clients. Server will send data in one port and receive data in other
port. Once data is sent the connection will be closed.

3. To have a distributed servers where a tree structure is maintained
and all the clients connected to the bottom most layer.

I would like to know how many socket connections can be kept open in
windows operating system.

Please help me to identify the correct design
approach.



thanks,
regards,
Jeevanand
7 Answers

Ashutosh Bhawasinka

11/4/2008 6:46:00 AM

0

Nash wrote:
> Hi,
> I want to develop a server application which can handle 1 million
> clients. I plan to use asynchronous tcp/ip sockets to handle clients.
> The communication is not frequent and the data transfered is also
> less(Max 100kb packet)
>
> I have some ideas to implement it
>
> 1. To have a single server which will service all the 1 million
> clients. Server will listen to the connections on a particular port
> and once connected will keep the connection open forever.
>
> 2. To have a single server which will service all the 1 million
> clients. Server will send data in one port and receive data in other
> port. Once data is sent the connection will be closed.
>
> 3. To have a distributed servers where a tree structure is maintained
> and all the clients connected to the bottom most layer.
>
> I would like to know how many socket connections can be kept open in
> windows operating system.
>
> Please help me to identify the correct design
> approach.
>
>
>
> thanks,
> regards,
> Jeevanand
>

1 Million connection! That's too much....But I suppose not all will
connect at a time.

Windows XP SP2 had limited the number of simultaneous TCP connection to
10. You should be using a server grade OS

The server application can listen on a fixed port say 5000. When a
client connects to the server, the server will receive the connection
request and will create a new socket (this is done automatically) and
will communicate with this new client using the new socket. It won't use
the initial (server) socket for communicating with the client. The
server application will continue to listen on port 5000 for new clients.
This port will be used only for the clients to connect to the server. No
data will be sent or received on this port/endpoint.

After a client has connected to you server application, you can then
initiate a new connection to the client if you want to have 2 different
sockets for 2 way communication.

Keeping the connection forever ??? why?? You will end up eating all the
system resources!! You must use a better design.

Peter Duniho

11/4/2008 7:07:00 AM

0

(microsoft.public.dotnet.framework and microsoft.public.vc.mfc removed
from follow-ups...there's really nothing in this thread related to either)

On Mon, 03 Nov 2008 22:45:34 -0800, Ashutosh Bhawasinka
<discussion@ashutosh.in> wrote:

> 1 Million connection! That's too much....But I suppose not all will
> connect at a time.

It is theoretically possible, on a robust enough server.

> Windows XP SP2 had limited the number of simultaneous TCP connection to
> 10. You should be using a server grade OS

This is definitely true.

> The server application can listen on a fixed port say 5000. When a
> client connects to the server, the server will receive the connection
> request and will create a new socket (this is done automatically) and
> will communicate with this new client using the new socket. It won't use
> the initial (server) socket for communicating with the client. The
> server application will continue to listen on port 5000 for new clients.
> This port will be used only for the clients to connect to the server. No
> data will be sent or received on this port/endpoint.

This is definitely not.

If the server port is 5000, then that's the port that _all_ of the
connections will use. It's true that a new socket will be created for
each connection, but they will all use the same port number.

> After a client has connected to you server application, you can then
> initiate a new connection to the client if you want to have 2 different
> sockets for 2 way communication.

Sockets are already bidirectional. There's no need to create a second
connection for two-way communication.

> Keeping the connection forever ??? why?? You will end up eating all the
> system resources!! You must use a better design.

If the clients are constantly in communication with the server, then
keeping the connection open as long as the client wants is better than
having the client repeatedly close and reopen connections. It really just
depends on what the application here is.

I'd say the most important thing for the OP to do is not cross-post so
widely. If he wants expert advice, he needs to post only to the
newsgroups where the network experts are participating. Posting to .NET
and/or MFC newsgroups, he's as likely to get bad information as good.

Pete

Volodymyr M. Shcherbyna

11/4/2008 9:19:00 AM

0

Read comments inline:

>> 1. To have a single server which will service all the 1 million
>> clients. Server will listen to the connections on a particular port
>> and once connected will keep the connection open forever.

I hardly believe any of Windows Operating System will be able to keep 1
million of opened TCP sockets (even server editions) even in 2008 year. Each
socket occupies some memory, so your machine can simply went out of memory.

>> 2. To have a single server which will service all the 1 million
>> clients. Server will send data in one port and receive data in other
>> port. Once data is sent the connection will be closed.

Not sure I understand this correctly. Server is a server, it has to listen
for clients. What kind of data does it send? Where does it send it? To
client? In this case client becomes not a client but a server :)

>> 3. To have a distributed servers where a tree structure is maintained
>> and all the clients connected to the bottom most layer.

Sounds better.

--
Volodymyr, blog: http://www.shche...
(This posting is provided "AS IS" with no warranties, and confers no
rights)
"Ashutosh Bhawasinka" <discussion@ashutosh.in> wrote in message
news:eFjNMhkPJHA.4224@TK2MSFTNGP04.phx.gbl...
> Nash wrote:
>> Hi,
>> I want to develop a server application which can handle 1 million
>> clients. I plan to use asynchronous tcp/ip sockets to handle clients.
>> The communication is not frequent and the data transfered is also
>> less(Max 100kb packet)
>>
>> I have some ideas to implement it
>>
>> 1. To have a single server which will service all the 1 million
>> clients. Server will listen to the connections on a particular port
>> and once connected will keep the connection open forever.
>>
>> 2. To have a single server which will service all the 1 million
>> clients. Server will send data in one port and receive data in other
>> port. Once data is sent the connection will be closed.
>>
>> 3. To have a distributed servers where a tree structure is maintained
>> and all the clients connected to the bottom most layer.
>>
>> I would like to know how many socket connections can be kept open in
>> windows operating system.
>>
>> Please help me to identify the correct design
>> approach.
>>
>>
>>
>> thanks,
>> regards,
>> Jeevanand
>>
>
> 1 Million connection! That's too much....But I suppose not all will
> connect at a time.
>
> Windows XP SP2 had limited the number of simultaneous TCP connection to
> 10. You should be using a server grade OS
>
> The server application can listen on a fixed port say 5000. When a client
> connects to the server, the server will receive the connection request and
> will create a new socket (this is done automatically) and will communicate
> with this new client using the new socket. It won't use the initial
> (server) socket for communicating with the client. The server application
> will continue to listen on port 5000 for new clients. This port will be
> used only for the clients to connect to the server. No data will be sent
> or received on this port/endpoint.
>
> After a client has connected to you server application, you can then
> initiate a new connection to the client if you want to have 2 different
> sockets for 2 way communication.
>
> Keeping the connection forever ??? why?? You will end up eating all the
> system resources!! You must use a better design.


Michael D. Ober

11/4/2008 1:13:00 PM

0

"Ashutosh Bhawasinka" <discussion@ashutosh.in> wrote in message
news:eFjNMhkPJHA.4224@TK2MSFTNGP04.phx.gbl...
> Nash wrote:
>> Hi,
>> I want to develop a server application which can handle 1 million
>> clients. I plan to use asynchronous tcp/ip sockets to handle clients.
>> The communication is not frequent and the data transfered is also
>> less(Max 100kb packet)
>>
>> I have some ideas to implement it
>>
>> 1. To have a single server which will service all the 1 million
>> clients. Server will listen to the connections on a particular port
>> and once connected will keep the connection open forever.
>>
>> 2. To have a single server which will service all the 1 million
>> clients. Server will send data in one port and receive data in other
>> port. Once data is sent the connection will be closed.
>>
>> 3. To have a distributed servers where a tree structure is maintained
>> and all the clients connected to the bottom most layer.
>>
>> I would like to know how many socket connections can be kept open in
>> windows operating system.
>>
>> Please help me to identify the correct design
>> approach.
>>
>>
>>
>> thanks,
>> regards,
>> Jeevanand
>>
>
> 1 Million connection! That's too much....But I suppose not all will
> connect at a time.
>
> Windows XP SP2 had limited the number of simultaneous TCP connection to
> 10. You should be using a server grade OS

Not entirely correct. XP has a limit of 10 Windows connections. I have an
XP box that consistently runs 85-100 TCP connections. However, I do agree
that you need a server grade OS, preferably a 64 bit server with lots of
memory.

>
> The server application can listen on a fixed port say 5000. When a client
> connects to the server, the server will receive the connection request and
> will create a new socket (this is done automatically) and will communicate
> with this new client using the new socket. It won't use the initial
> (server) socket for communicating with the client. The server application
> will continue to listen on port 5000 for new clients. This port will be
> used only for the clients to connect to the server. No data will be sent
> or received on this port/endpoint.
>
> After a client has connected to you server application, you can then
> initiate a new connection to the client if you want to have 2 different
> sockets for 2 way communication.
>
> Keeping the connection forever ??? why?? You will end up eating all the
> system resources!! You must use a better design.
>

Figure out a way to implement idle time socket closures and ensure your
clients can handle the socket being closed by the server.

Mike.


Dave Lowther

11/5/2008 7:35:00 AM

0

"Ashutosh Bhawasinka" <discussion@ashutosh.in> wrote in message
news:eFjNMhkPJHA.4224@TK2MSFTNGP04.phx.gbl...

> Windows XP SP2 had limited the number of simultaneous TCP connection to
> 10. You should be using a server grade OS

Have you tested this, or do you have a URL to a good source that confirms
the above ?

I know XP limits the number of *uncompleted* TCP connections (SYN sent but
no ACK received yet).

I've heard that XP lmitis the number of connections to shared files or
printers.

But I've not come across the limit of 10 TCP connections that you mention.

Dave.


David Schwartz

11/5/2008 10:37:00 AM

0

On Nov 4, 11:34 pm, "Dave Lowther" <da...@snsys.com> wrote:
> "Ashutosh Bhawasinka" <discuss...@ashutosh.in> wrote in message
>
> news:eFjNMhkPJHA.4224@TK2MSFTNGP04.phx.gbl...
>
> > Windows XP SP2 had limited the number of simultaneous TCP connection to
> > 10. You should be using a server grade OS
>
> Have you tested this, or do you have a URL to a good source that confirms
> the above ?
>
> I know XP limits the number of *uncompleted* TCP connections (SYN sent but
> no ACK received yet).
>
> I've heard that XP lmitis the number of connections to shared files or
> printers.
>
> But I've not come across the limit of 10 TCP connections that you mention.
>
> Dave.

You are correct. This is an often-repeated myth.

Rumor is that at one time (well before XP, I think) Microsoft was
going to do this (on Windows 2000 non-server maybe). A company that
felt the behavior was absurd had developed a drop-in replacement TCP/
IP stack that didn't have this limitation, and Microsoft relented. I
have no idea if this is true or false.

DS

Alun Jones

11/5/2008 5:25:00 PM

0

"Ashutosh Bhawasinka" <discussion@ashutosh.in> wrote in message
news:eFjNMhkPJHA.4224@TK2MSFTNGP04.phx.gbl...
> 1 Million connection! That's too much....But I suppose not all will
> connect at a time.

Certainly if you count _just_ the amount of memory you'll take up servicing
that many client connections, you can see that this is essentially
impossible for anything less than a seriously parallel server architecture.

> Windows XP SP2 had limited the number of simultaneous TCP connection to
> 10. You should be using a server grade OS

No - Windows XP SP2 limited the number of simultaneous _half-open_
_outgoing_ connections to 10.

There's a HUGE difference.

> The server application can listen on a fixed port say 5000. When a client
> connects to the server, the server will receive the connection request and
> will create a new socket (this is done automatically) and will communicate
> with this new client using the new socket. It won't use the initial
> (server) socket for communicating with the client. The server application
> will continue to listen on port 5000 for new clients. This port will be
> used only for the clients to connect to the server. No data will be sent
> or received on this port/endpoint.

This is wrong. A TCP server listening on port 5000 will accept connections
on port 5000, and those connections will _stay_ on port 5000. You will not
see a different port. That doesn't mean that you won't see a new endpoint
for each connection.

> After a client has connected to you server application, you can then
> initiate a new connection to the client if you want to have 2 different
> sockets for 2 way communication.

No, that's not necessary either. Socket communication in TCP and unicast UDP
is two-way. Only multicast / broadcast is one-way.

> Keeping the connection forever ??? why?? You will end up eating all the
> system resources!! You must use a better design.

I think this person must use a training course or book to learn how to
design and program network code - there are _way_ too many crappy network
programs out there, and he's just going to add one more, trying to learn it
piecemeal through newsgroup postings.

Alun.
~~~~
--
Texas Imperial Software | Web: http://www....
23921 57th Ave SE | Blog: http://msmvps....
Woodinville WA 98072-8661 | WFTPD, WFTPD Pro are Windows FTP servers.
Fax/Voice +1(206)428-1991 | Try our NEW client software, WFTPD Explorer.