Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2007-03

Re: Inter Process Communication

5 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Jason P Sage
Michael Schnell wrote
Why not use TCP/IP to send informations from one program to another ?

In

Show quoted text 6 lines
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

Reply by email

Unknown author
to Jason P Sage
Jason P Sage wrote 75 lines
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.

Did you check the O-PSP :
http://www.psp.furtopia.org/cgi-bin/psp/news.psp and http://sourceforge.net/project/showfiles.php?group_id=145841. The O-PSP is going to handle the requests using multi-threading mechanism while it doesn't need to install any apache module. Currently, It is developed for Linux. So, having a big application (regarding its size) isn't a problem. I used the "named pipes" to communicate between the dispatcher main application.

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.

But as far as I know, the TCP/IP has some (huge) overheads and reduces the performance specially if your site has many visitors.

Show quoted text 14 lines
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 _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Michael Schnell
to Jason P Sage: In machines. Hi Micheal. Glad you asked. First of all - I just may use the Sockets Unit -…
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.

I understood that you use multiple _programs_. If you use multiple _threads_ (shared memory, only here you can have thread-safety-issues). You need to do quite different considerations.

-Michel

Reply by email

Vincent Snijders
to Jason P Sage: In machines. Hi Micheal. Glad you asked. First of all - I just may use the Sockets Unit -…
Jason P Sage wrote 5 lines
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).

<snip fastcgi mentioned several times>

Show quoted text 12 lines
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). 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.

To give you a headstart, you might want to is a side project of lNet (See http://wiki.lazarus.freepascal.org/lNet) and is a http server written by Micha Nelissen with fpc and supporting fastcgi.

Vincent

Reply by email

George Birbilis
to Unknown author: Did you check the O-PSP : http://www.psp.furtopia.org/cgi-bin/psp/news.psp and…

Haven't read this thread, so I might be off-topic a bit in the following:

On Windows the best way to copy data in my opinion is WM_COPYDATA message, but I'm not sure if on Vista it will work ok (haven't tried). If you want to try it see http://plugs.onestop.net

----------------
George Birbilis ()
Computer & Informatics Engineer
Microsoft MVP J# for 2004-2007
Borland "Spirit of Delphi"
3D, QuickTime, QTVR, Java, Delphi,
ActiveX, .NET components, Robotics
http://www.kagi.com/birbilis
http://birbilis.spaces.live.com

Reply by email