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

semuel semuel at semuel.co.il
Sun May 30 14:16:54 PDT 2004


Hello There.

My opinion is that select is the best.
There are servers written around it, that carry huge amount of load.
It's good when your server does:
1. Very little processing work for every packet.
2. NO disk access.
If so, and you program carefully, (even a non-blocking write can block if
client stopped accepting packets) select is the tool.
Just remember - if anything blocks, all the server is waiting. So disk
access can block your entire server.
And check your platform - there are OSs that have a limit on the number of
socket that can be used through one select. 

Semuel.


-----Original Message-----
From: perl-bounces at perl.org.il [mailto:perl-bounces at perl.org.il] On Behalf
Of Yuval Yaari
Sent: Sunday, May 30, 2004 11:48 AM
To: Perl in Israel
Subject: [Israel.pm] Building a threaded server using Perl?

Hi,

I wrote a few servers that currently handle a few hundreds of users 
without a problem.
I use IO::Select which, as far as I understand, will make everything 
really slow once the server hits bigger loads.
My company wants me to make sure everything is "future-proof", so once 
we have more clients per server - things will stay smooth.

I can't stress test my server like I wish I could, because we're talking 
about imitating large amounts of data - which should always vary 
(otherwise I ignore it :) also hashes won't grow, etc).

Basically I have a main hash (usually 2 or 3, actually) where I keep all 
the data from all the connections I have.
There's some sort of CLI (accessable via telnet) which shows all 
info/stats from all current connections (read: I sum up the info from 
the hash).

I open 3 separate ports (1 for clients, 1 for some admin program that 
some guy wrote a long time ago, before I even joined this company [over 
2 years now :)], 1 for CLI).

My main questions:
1) Are threads in Perl reliable enough (under Linux, if it matters)?
2) Why should/shouldn't I rewrite my servers?
3) In what way should I write a threaded server (thread per client? 
thread for read and thread for write per client?)?
4) Any problems letting all threads access a main (shared...) hash? I 
must show summary and it's very easy with Perl's data-structures.
5) Your experiences & examples are more than welcome :)


  --Yuval

_______________________________________________
Perl mailing list
Perl at perl.org.il
http://www.perl.org.il/mailman/listinfo/perl





More information about the Perl mailing list