[Chicago-talk] threading Question

Steven Lembark lembark at wrkhors.com
Sun Feb 14 12:45:22 PST 2010

On Sun, 14 Feb 2010 02:27:15 -0600
Jonathan Rockway <jon-chicagotalk at jrock.us> wrote:

> * On Sat, Feb 13 2010, Zane C.B. wrote:
> > The only issue I've ever run into, is that it is a bitch, passing
> > information between between each instance.
> Hence threads.
> (But not ithreads, which is just fork without copy and write.)
> I really recommend using Coro for network daemons.  It will easily
> handle 30,000+ open and idle connections.  (And only that few because
> that's when my machine runs out of file descriptors.)  If you need to
> use all 4 CPUs, run four copies of your daemon.

Under all but the fewest of cases, threading 
offers so much more pain that data passing that 
forking will usually be a better approach -- at 
least on *NIX [VMS spawn's have their own problems
and Windawg doesn't support real forks].

The amount of data that has to be moved is usually
small, and success/failure or a set of pre-defined
choices can easily be handled by exit codes.

If you have to move more data, there are standard
approaches for socket interfaces -- POE being the
most adaptable and thus complicated, simple listen+
select being the easiest also well supported by 
perly modules.

Shared memory is quite simple to manage with Perl
and has generally less overhead than threading.

An attitude of first verifying that forks will
accomplish your needs reasonably before trying
threads will pay off handsomly in reduced pain
over the long term.


Steven Lembark                                            85-09 90th St.
Workhorse Computing                                 Woodhaven, NY, 11421
lembark at wrkhors.com                                      +1 888 359 3508

More information about the Chicago-talk mailing list