From: "David Schwartz" <davids@webmaster.com>
To: "kirk bae" <justformoonie@hotmail.com>, <linux-kernel@vger.kernel.org>
Subject: RE: So, Poll is not scalable... what to do?
Date: Wed, 12 Nov 2003 23:52:55 -0800 [thread overview]
Message-ID: <MDEHLPKNGKAHNMBLJOLKIEMEHOAA.davids@webmaster.com> (raw)
In-Reply-To: <LAW12-F60bw5TYIo9WF0002bec8@hotmail.com>
> If poll is not scalable, which method should I use when writing
> multithreaded socket server?
'poll' is quite scalable. It's only not scalable if you make stupid
assumptions about how people use it.
> What is the most efficient model to use?
>
> Is there a "standard" model to use when writing a scalable multithreaded
> socket serve such as "io completion ports" on windows?
If all your sockets are equally active, having a bunch of threads each
'poll'ing 1,024 descriptors is perfectly scalable. 64,000 is not a problem,
and that's about the kernel limit if memory serves me.
If you have active and inactive sockets, sort them. Have some threads that
'poll' on large numbers of inactive sockets and some that 'poll' on small
numbers of active sockets. This will scale quite well as the expensive
'poll' calls are infrequent compared to the cheap ones.
> From the "Microbenchmark comparing poll, kqueue, and /dev/poll",
> kqueue is
> the way to go. Am I correct?
Yes, if you're using a kernel that supports it. It will pretty much always
be more efficient than 'poll'.
> Also, why is it that poll doesn not return with "close signal" when a
> thread-1 calls poll and thread-2 calls close on a sockfd1? It seems that
> poll only handles close signal when a client disconnects from the server.
> I've seen this mentioned here before, has it been fixed?
You can never ever make this work. There will always be a race condition no
matter what you do. (How can you ever be sure thread-2 doesn't all 'close'
jsut before thread-1 calls 'poll'?) So do not ever do this. Do not ever
release a shared resource while a thread is or might be using it because it
might also be about to use it!
DS
next prev parent reply other threads:[~2003-11-13 7:53 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-11 23:52 kirk bae
2003-11-12 3:52 ` Jeff Garzik
2003-11-12 5:32 ` Willy Tarreau
2003-11-12 23:26 ` bill davidsen
2003-11-13 0:32 ` Davide Libenzi
2003-11-13 0:54 ` Nick Piggin
2003-11-13 12:02 ` Bill Davidsen
2003-11-12 23:23 ` bill davidsen
2003-11-13 1:06 ` Bernd Eckenfels
2003-11-13 7:52 ` David Schwartz [this message]
2003-11-13 18:25 Dan Kegel
2003-11-13 23:10 kirk bae
2003-11-14 0:52 ` Mark Mielke
2003-11-14 0:27 Dan Kegel
2003-11-14 18:57 Frederic Rossi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=MDEHLPKNGKAHNMBLJOLKIEMEHOAA.davids@webmaster.com \
--to=davids@webmaster.com \
--cc=justformoonie@hotmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®