Re: [SQL] Low level socket locking...
От | Daniele Orlandi |
---|---|
Тема | Re: [SQL] Low level socket locking... |
Дата | |
Msg-id | 35C606A0.CD65F5B6@orlandi.com обсуждение исходный текст |
Ответ на | Low level socket locking... (M Simms <grim@argh.demon.co.uk>) |
Список | 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 -------------------------------------------------------------------------------
В списке pgsql-sql по дате отправления: