[fpc-devel] Inter Process Communication

Jason P Sage jasonpsage at jegas.org
Mon Mar 5 13:25:26 CET 2007


Michael Schnell Wrote:

>Why not use TCP/IP to send informations from one program to another ?
In 
>Linux this should perform at least as well as anything else, in Windows

>named pipes or windows messages with "attached" shared memory blocks 
>might perform better.

>Moreover you now easily can split the application between multiple
machines.

>-Michael

Hi Micheal. Glad you asked.

First of all - I just may use the Sockets Unit - I recently asked for
whatever changes need to occur in the demo programs "server" and
"client" in the FPC 2.0.4 manual (around pg 1056) of the RTL PDF
documentation because I'm looking into this.

What I'm trying to do is speed up how my web server application runs -
which is entirely written in Free Pascal.

I used CGI for portability - but to counter the delay of loading
involved CGI executables - I created a very thin CGI client (50k on
Win32 - unfortunately - 250k+ on Linux - (something about the smart
linking isn't as good on linux). 

I used only "non-class" libs and non-sysutils (because of the overhead
loading the class code (Around 200k).

The idea - which is similar to FastCGI - is by having a small CGI client
- that can hopefully execute fairly quickly - pass the CGI environment
to a multithreaded daemon - and wait for and then send the response - I
could get speed + portability. I used a binary filebased IPC. (Which is
actually pretty fast because I used block reads etc. But not as fast as
other means could be like shared mem or tcp/ip.. both of which explode
the cgi EXE filesize)

Unfortunately - I'm only getting 8-9 requests per second. Partly due to
the "unique filename" generator - which sometimes fails in Windows -
(Write Back Cache possibly on USB external Harddrives ..can't shut it
off) and the Linux - well the 250k+ hurts no matter what I do.

I tried the simpleipc unit supplied with freepascal to try and eliminate
the the file based IPC I wrote - but in Linux - it was awful - and
seemed to have symptoms of thread safety - could be my end or FPC rtl -
I'm not sure. Regardless I abandoned it because in Win32 - CGI
applications don't have the priviledges to be able to get window handles
- so simpleipc unit only works from the command line and not when
launched from inside apache, lighttpd or MyServer.

My next two agendas are creating my own web server - possibly using the
sockets unit if I can see a working demo that runs on both linux and
win32. I'd prefer to the FPC RTL version "sockets"; second - I may go
full bore FastCGI, which is very clear on how its supposed to work - but
documentation is lacking for setting it up for non-php and non-ruby
solutions (I'll figure it out eventually).

The PSP "Pascal Server Pages" - just isn't the right framework - or I
would use it. It suffers from the same issues as CGI normally does - it
just gets by for awhile - but when you application gets "big" - it seems
to have the same issues as other CGI implementations.

I definitely see the advantages of the TCP/IP between the web server and
the application for scalability - etc. and I will do that even if I make
my own web server - simply because that makes sense.

FastCGI seems the right way to go - but I've yet to get one of the
FastCGI programs - like echo or threaded to actually return something in
a browser after much configuration experiments.

Wish me well and thanx for your advice.

Best Regards,
Jason P Sage





More information about the fpc-devel mailing list