You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "Reilly, Thomas" <Th...@Dscie.Com> on 2000/06/12 12:02:12 UTC

mod-perl and IPC

hi,
	I have to write an application that processes a http request using
mod_perl. The mod_perl script extracts XML from the request and this is then
passed to a process written in C which takes care of processing the XML,
logging into a database updating records and sending a response back to the
mod_perl script which sends the appropriate response back to the client.

I initally had mod_perl spawn the C process (which implements Unix Domain
Sockets to talk to mod_perl) in the background and sleep for a second to
allow the C socket server to be execed and then have mod-perl connect:
system "./cserver &" .
sleep(1);
socket(CLIENT,sockaddr_un("/home/httpd/perl/UD_socket"))
connect(CLIENT,...

This worked for a single request but obviously isn't a very good idea as
what happens when you have say a thousand requests? How do I handle the
reading and writing to the socket for alot of requests. The socket becomes a
bottleneck!! Is there any way to allocate sockets dynamically?? or say
choose from a pool of sockets?
I am thinking about implementing a Daemon process that communicates with
mod_perl using IPC, spawns the C socket server which will do it's stuff and
return info to the daemon which returns via IPC to mod_perl. The problem
here again is multiple requests still use the same (i think!) unix domain
socket (which is IPC .V. mod_perl and Daemon). The idea behind this
hair-brained scheme was to not have mod_perl forking/execing the whole
Apache web server for each request. 

Has anybody got any better ideas as i'm sure this is pretty crazy!!
especially on overcoming the bottleneck problem. I'm really hoping there is
an easier way than this. 

thanks in advance!


Thomas Reilly
Software Consultant,

Distributed Software Consultancy Ltd.,
Ballybrit Business Park,Galway,Ireland.
Tel: +353 (91) 760541 Fax: +353 (91) 760542
e-mail: Thomas.Reilly@dscie.com
web: http://www.dscie.com