RE: [Zope] Database connections
Oleg writes:
I've finished large project using pure CGI concept (I used Neale's html.py). Now I (and my boss) are thinking of switching to Zope, or at least ZTemplates.
While playing with Zope and SQL (I am using Postgres, hence ZPygres Database Adapter), I found that Zope, when loaded into memory by Zope.cgi (I am using Apache, and need to use in the future) opens a database connection for every Folder where I created Connection object.
Ahh, no need. Just put one Database Connection object in the top folder and all the subfolders will "acquire" it. That is, any SQL Method defined lower down can use it.
It is bad, as I have many databases, so Zope eats up memory. Another problem - what would do Zope if I restart Postgres (so all current connections break)? Would Zope reestablish connections or just report error?
It should re-establish the connection. If it doesn't then there's a bug. This works fine with all the Database Adapters I've used.
How could I limit number of connections Zope opens? How could I
There is one connection per Database Connection object.
define a timeout, after which Zope close a connection if there is no
Hmm, this is quite a hard thing to do, unfortunately.
activity between Zope and Postgres? and reestablish connection when application ask for SQL data?
With ZTemplates and CGI all these questions has one easy (but not so nice) answer - there is no constant connection, a connection established on every CGI invocation.
Of course this means the CPU gets a tremendous beating on every request and the response time goes down.
PS. BTW, I wrote short introduction to Zope in Russian: http://sun.med.ru/~phd/Russian/Zope/ Any Russian here to verify my understanding of Zope?
Mind if I add a blurb to the Zope News about it? --Paul
On Tue, 23 Mar 1999, Paul Everitt wrote:
While playing with Zope and SQL (I am using Postgres, hence ZPygres Database Adapter), I found that Zope, when loaded into memory by Zope.cgi (I am using Apache, and need to use in the future) opens a database connection for every Folder where I created Connection object.
Ahh, no need. Just put one Database Connection object in the top folder and all the subfolders will "acquire" it. That is, any SQL Method defined lower down can use it.
There are connections to different databases. So you said "one connection to one database"?
It is bad, as I have many databases, so Zope eats up memory. Another problem - what would do Zope if I restart Postgres (so all current connections break)? Would Zope reestablish connections or just report error?
It should re-establish the connection. If it doesn't then there's a bug. This works fine with all the Database Adapters I've used.
I'll retest, but currently, when I ask ZPygresDA to close connection, Zope reports "the site has technical difficulties" when I'm trying to access the application.
define a timeout, after which Zope close a connection if there is no Hmm, this is quite a hard thing to do, unfortunately.
Bad news. :(
PS. BTW, I wrote short introduction to Zope in Russian: http://sun.med.ru/~phd/Russian/Zope/ Any Russian here to verify my understanding of Zope?
Mind if I add a blurb to the Zope News about it?
It's Ok. I am not sure about correctness. And it is definetely far from complete. I'll continue working on it.
--Paul
Oleg. ---- Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/ Programmers don't die, they just GOSUB without RETURN.
Paul Everitt wrote:
It is bad, as I have many databases, so Zope eats up memory. Another problem - what would do Zope if I restart Postgres (so all current connections break)? Would Zope reestablish connections or just report error?
It should re-establish the connection. If it doesn't then there's a bug. This works fine with all the Database Adapters I've used.
I've just hit something similar in the mysql client. The mysql client has a time-out to close the connection with the server. I'm using it in a test environment where it isn't accessed frequently. The connection is automatically closed and I have to manually close and open the database connection. Has anyone already fixed it? Excuse me if it has already been asked in the list, but the egroups site isn't working. regards, -- Paulo Eduardo Neves PUC-Rio de Janeiro Pager: Central: 292-4499 cod. 213 99 64 ou use a URL: http://www.learn.fplf.org.br/neves/mensagempager.html
participants (3)
-
Oleg Broytmann -
Paul Everitt -
Paulo Eduardo Neves