pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Daniele Orlandi <daniele@orlandi.com>
To: M Simms <grim@argh.demon.co.uk>
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] Low level socket locking...
Date: Mon, 03 Aug 1998 20:51:12 +0200
Message-ID: <35C606A0.CD65F5B6@orlandi.com> (raw)
References: <199808031735.SAA20880@argh.demon.co.uk>

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
-------------------------------------------------------------------------------



view thread (3+ messages)

Message-ID: <35C606A0.CD65F5B6@orlandi.com>
Permalink:  ../35C606A0.CD65F5B6@orlandi.com/
Also on:    postgresql.org/message-id/35C606A0.CD65F5B6@orlandi.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: daniele@orlandi.com, grim@argh.demon.co.uk
  Subject: Re: [SQL] Low level socket locking...
  In-Reply-To: <35C606A0.CD65F5B6@orlandi.com>
  References: <199808031735.SAA20880@argh.demon.co.uk> <35C606A0.CD65F5B6@orlandi.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox