Re: [SQL] Low level socket locking...

From: Daniele Orlandi <daniele(at)orlandi(dot)com>
To: M Simms <grim(at)argh(dot)demon(dot)co(dot)uk>
Cc: pgsql-sql(at)postgreSQL(dot)org
Subject: Re: [SQL] Low level socket locking...
Date: 1998-08-03 18:51:12
Message-ID: 35C606A0.CD65F5B6@orlandi.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

M Simms wrote:
>
> This is set up in this way because I need to do many similar jobs with the
> database, but obviously, every time the web page is accessed, a new copy of
> the cgi script is created, and if I were to create a new connection to the
> database every time this would a) mean spawning LOTS of copies of the
> postgres backend, very slow, and b) I wouldnt get the advantages of any
> caching that is done.
> Thus I send a simple message from the CGI to the handler process, which
> then interracts with the database, and returns the result.

AFAIK, you have three possibilities:

- Write a daemon who waits for connections from the CGI and does all the
database-related stuff. This is slightly hard to implement but the most flexible
solution, probably not the best thought...

- Use FastCGI (http://fastcgi.idle.com), it's very similar to the first
solution, since the fastcgi module will spawn one or more persistent processes
and will dispatch the requests to them thru sockets (eventually, you may move
the processes on a different machine).
You would open the database connection only once when the process is spawned.
Advantages: Very fast as the processes may be written in C.

- Use PHP3 with pg_pConnect (persistent Connect), the PHP module will mantain a
cache of open connections and efficently reuse each of them.

Hope this helps...

Bye!

--
Daniele

-------------------------------------------------------------------------------
"Oh, I've seen copies [of Linux Journal] around the terminal room at The
Labs."
(By Dennis Ritchie)
-------------------------------------------------------------------------------
Se telecom italia aggiungesse uno scatto al giorno ad ogni abbonato, dal
primo Gennaio avrebbe rubato 682.040.000.000 Lire.
-------------------------------------------------------------------------------
Daniele Orlandi - Utility Line Italia - http://www.orlandi.com
Via Mezzera 29/A - 20030 - Seveso (MI) - Italy
-------------------------------------------------------------------------------

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message John Edstrom 1998-08-03 18:54:31 Re: [SQL] locked my keys in the car
Previous Message dave madden 1998-08-03 18:01:51 Re: [SQL] Low level socket locking...