Completion ports won't apply to your connections to SQL
Server. But, for
a good architectural description of IO Completion Ports
(IOCP) you can see
Chris Mullins' blog entry "Windows Sockets and
Threading: How well does it
scale?" [1] which describes the various different type
of threading
options of a multi-user server (in this case, a socket
server) and IOCP
and why certain designs aren't scalable. The IOCP aspect
of async IO is
new to .NET 2.0, as far as I know...
If you're dealing with multiple connections to a remote SQL
server, that
would likely fall under the "a thread needs to exist
but doesn't need much
CPU because it's mostly waiting" scenario. Since,
from a memory
perspective, only a limited number of threads can exist at a
time, a
thread pool would be your best bet here. The CLR thread
pool is usually
sufficient but there are caveats (like the pool is shared
with the CLR and
the rest of your application) and you may want to consider a
home-grown
pool. But, basically a configurable but fixed set of
threads is allowed
to run and any request beyond that are queued. Jon Skeet
has some good
articles on using the thread pool:
http://www.yoda.arachsys.com/csharp/threads/threadpo
ol.shtml
http://w
ww.yoda.arachsys.com/csharp/threads/
He's also posted comments on the caveats of the CLR thread
pool; but, I
don't have a link to them off hand.
[1] http://www.coversant.net/dotnetnuke/Defa
ult.aspx?tabid=88&EntryID=10
On Fri, 4 Aug 2006 08:26:09 +0100, Steve W <lsl BTCONNECT.COM> wrote:
>Thanks Peter.
>
>Basically the tasks tend to be querying a SQL server,
generating XML and
>saving that back in to the SQL Server. Also sending
emails.
>
>Any suggestions as to where I could read about async IO
and completion
ports
>? This is all .Net 2.0 btw.
>
>Regards
>
>Steve
>
>-----Original Message-----
>From: Discussion of development on the .NET platform
using any managed
>language [mailto OTNET-CL
R DISCUSS.DEVELOP.COM] On Behalf Of Peter
Ritchie
>Sent: 03 August 2006 21:58
>To: DOTNET-CLR DISCUSS.DEVELOP.COM
>Subject: Re: [DOTNET-CLR] Maximum Number of Threads to
Use
>
>Theoretically the maximum number of threads on a system
is only limited by
>system resources.
>
>Realistically, system resources are organized in a way
that severely limit
>how many threads can exist per process (let alone
active). I recall
>someone doing a little test and found that things
started to fail around
>50 threads; but, I don't remember where that was.
>
>Keep in mind, the more actively running threads that
share a processor the
>more context switching will occur for your application,
reducing its
>performance.
>
>General rule of thumb: one devoted worker thread per
processor. This
>really only applies if you're parallel processing. If
you have some
>threads that don't use the CPU much (UI threads, for
example) you can get
>away with more threads (like one UI thread and one
background worker
>thread).
>
>If you're talking in the context of very latent IO with
more than about 50
>threads, it's best to let the system create the threads
for you rather
>than creating one thread per IO operation. This can be
done in .NET with
>Asynchronous IO (depending on the OS you're running
this will translate
>into completion ports, which is even better)
>
>Depending on the system you're on, I doubt you could
event approach 1000
>threads.
>
>Under what context is this, IP server?
>
>-- Peter
>Microsoft MVP, Visual Developer - Visual C#
>http://www.peterRit
chie.com/blog/
>
>On Thu, 3 Aug 2006 21:17:29 +0100, Steve W <lsl BTCONNECT.COM> wrote:
>
>>I suspect the answer to this question is 'It
depends', but I'd like to
>know
>>what it depends on.
>>
>>I have a windows service that performs some tasks
for each user created
on
>>the system. I was thinking that I would create a
new thread for each
user
>>and have each thread do the work for the user.
>>
>>Say I have 1000 users, then in theory I would be
running 1000 threads
>>(although I suspect the first ones would finish
before the last ones
>>started), which doesn't sound great to me.
>>
>>Should I limit my service to a certain number of
threads, divide the
>number
>>of users by the number of threads and have each
thread process that
number
>>of users ?
>>
>>If so how do I work out how many 'a certain number
of threads' is ?
>>
>>If not, what is the best way to handle this
situation ?
>
>===================================
>This list is hosted by DevelopMentorR http://www.develop.com
>
>View archives and manage your subscription(s) at
http://discuss.develop.com
>
>===================================
>This list is hosted by DevelopMentorŪ http://www.develop.com
>
>View archives and manage your subscription(s) at
http://discuss.develop.com
===================================
This list is hosted by DevelopMentorŪ http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|