[Israel.pm] Building a threaded server using Perl?

Oron Peled oron at actcom.co.il
Sun May 30 10:51:55 PDT 2004


On Sunday 30 May 2004 15:11, Yuval Yaari wrote:
> I also want to emphasise that I'm not looking for OS/kernel solutions.

Wishfull thinking... see below:

> I just want my server to be able to concurrently serve a few clients 
> instead of iterating over all of them one by one - so if I have 10,000 
> clients connected, it won't take ages to send them all something

There is a big difference between "few clients" and >10K clients.
The reference I sent shows that even OS that live natively on the web
(Unices and Linux) should resort to special features to handle that
kind of load.

> What I forgot to ask: is there copy-on-write when using threads and 
> modifying a shared hash?

You just defined the semantics of fork() on any Unix/Linux in the last 20
years. Fork() gives you the safely of separate processes but the actuall
copy of pages is done only when a page is touched (that's why it's only
in the last ~20 years, since you need hardware support for this).

BTW: Even if you don't care about the added safety, note that doing all
the locking/unlocking stuff in a multi-threaded application does not come
free and *may* create worse performance than two separate processes with
their own protected memory spaces. (depending on the specifics of
application of course).

-- 
Oron Peled                             Voice/Fax: +972-4-8228492
oron at actcom.co.il                  http://www.actcom.co.il/~oron

Code Red, Blue or Green there all a symptom of a far more pervasive
and insidious virus, it costs around $200.
                                                -anonymous




More information about the Perl mailing list