Re: blocking non blocking



The author mean case where you have nothing to do before all data arrive ,
so you need to wait any case , but if you can/have to do with data coming
( even parts ) async sockets preferable , OTOH if you need to do some work
not connected to incoming data on the same thread , async sockets have to be
used.
Arkady

"Daniel" <DanielV@xxxxxxxxxxxxxxxx> wrote in message
news:ekvP5zIoGHA.1332@xxxxxxxxxxxxxxxxxxxxxxx
Ok now i am very confused...here is why i think non blocking is less
efficient, a quote from TCP/IP sockets in c# Practical guide for
programmers:

"like polling, non blocking sockets typically involve some busy waiting
and are not very efficient"

So you see why i am confused? I am getting conflicting opinions :( Can
anyone explain and put me straight?


"Alexander Nickolov" <agnickolov@xxxxxxxx> wrote in message
news:ekoQv3snGHA.1664@xxxxxxxxxxxxxxxxxxxxxxx
Why do you think non-blocking is less efficient? There's no
real difference for a single client (occasional three system
calls instead of one), but for multiple clients you dramatically
cut on the number of threads needed thus significantly improving
performance with non-blocking or overlapped model. (BTW,
overlapped is the better deal of the two...)

I have some vague recollection from NT4 days that an NT4
server of those days (one CPU) crashed with under 1000
threads. Just to put this into perspective, even if you can manage
somehow a server with 50K threads, it'll be prohibitively
more expensive than an equivalent server using a non-blocking
or overlapped I/O servicing 50K clients. Dual core won't
cut it a by a long shot! (Perhaps 16 or 32 dual cores...)

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@xxxxxxxx
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================

"Daniel" <DanielV@xxxxxxxxxxxxxxxx> wrote in message
news:OCXwClHnGHA.2256@xxxxxxxxxxxxxxxxxxxxxxx
I have currently designed it using asynchronous threads. From what i have
read and learnt about blocking and non blocking, it seems non blocking is
less efficient than blocking but i have to beware of deadlock?

I am not using select and wait. I spawn a thread per client which stays
acive for as long as the client is connected. So theoretically i could
have 50k threads running at any time. My server would definitely be dual
core, so 25k threads per cpu to handle, and i may even use 2 multi core
servers and load balancing.

Does that sound like it could handle it? Is my current set up ok for how
scalable a solution i require?

"Alexander Nickolov" <agnickolov@xxxxxxxx> wrote in message
news:OdqRGOHnGHA.4240@xxxxxxxxxxxxxxxxxxxxxxx
50K open sockets definitely calls for IOCP and a thread pool!
It may also call for multi-CPU or multi-core machine I might add...
The other model that can deal with lots of sockets is asynchronous
socket I/O, but it doesn't scale as much. With select and wait
functions you are limited to 64 sockets per thread. Blocking
sockets can't go beyond a handful of sockets or risk major
latency introduced at your server...

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@xxxxxxxx
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================

"Daniel" <DanielV@xxxxxxxxxxxxxxxx> wrote in message
news:uowZ029mGHA.4620@xxxxxxxxxxxxxxxxxxxxxxx
I may need to handle up to 50,000 clients at any given time. Is that
how scalable you are talking, is blocking ok for this kind of size? My
data size is tiny though, at largest 8Kb - 16Kb roughly at any given
time.



"Alexander Nickolov" <agnickolov@xxxxxxxx> wrote in message
news:%23%23kqq46mGHA.2252@xxxxxxxxxxxxxxxxxxxxxxx
ioctlsocket with FIONBIO or one of the select API calls that
do it for you (WSAEventSelect and WSAAsyncSelect).

The advantage is you don't need two threads per socket per
client so your server can actually scale to more than a handful
of clients. The disadvantage is the somewhat harder logic needed
to implement non-blocking communication. However, for a truly
high performance scalable server you want ovelapped I/O and
a completion port used with a thread pool, which is significantly
harder to implement...

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@xxxxxxxx
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================

"Daniel" <DanielV@xxxxxxxxxxxxxxxx> wrote in message
news:%23yE41I6mGHA.3376@xxxxxxxxxxxxxxxxxxxxxxx
Hey guys

My socket connection is blocking=true, and i have multiple clients
connecting to my server.

The more clients i have the more problems i have.

How do i set the socket to non blocking? what are the disadvantages
of this? What are the advantages of this?

Thanks















.



Relevant Pages

  • sockets, closing and TIME_WAIT
    ... During heavy load the server can't follow anymore because the sockets ... my server should be able to handle 10 clients connecting ... This gets a free position in the array of connections, ...
    (comp.unix.programmer)
  • Re: Ideas required for usage of sockets API for efficient network programs
    ... I am evaluating various methods of using sockets API for a network ... The server reads data from clients and writes data to clients. ...
    (comp.os.linux.development.apps)
  • Re: Socket programming: Command and Data socket
    ... example of how one could implement a program that uses two sockets for ... this working for a long time, but I guess my design is wrong. ... multiple clients connecting from the same or different machines. ... clients asks for a list of files and the server returns this. ...
    (comp.unix.programmer)
  • Re: Moving files from clients to the server
    ... I'm not very familiar with sockets but I'll look into that, ... >> files should be passed to the server. ... the fastest way to create them is on the clients' machines. ... >> Another solution is to steam the files over the network. ...
    (microsoft.public.vc.atl)
  • Re: blocking non blocking
    ... somehow a server with 50K threads, ... or overlapped I/O servicing 50K clients. ... read and learnt about blocking and non blocking, ... The other model that can deal with lots of sockets is asynchronous ...
    (microsoft.public.win32.programmer.networks)