|
Norman Tindall
NormanTindall at zdisk.net
Fri Aug 18 17:30:46 EDT 2006
Hello Richard,
RL> On Friday 18 August 2006 19:26, Norman Tindall wrote:
>> Don`t know how about publisher and PSP, but in handler
>> you always can at the end of processing, just before
>> return apache.OK close connection
RL> Yes, but I want to avoid opening and closing the connection to Berkeley DB XML
RL> for /every/ request as its quite slow to connect. Thats why I open it when
RL> the server starts and wanted to be able to close it when the server shuts
RL> down.
Hmm.. why dont you use a connection pooling?
Here is some examples of code, i never tested them,(because i need
a more complicated pool that will connect to different
databases and select db according to a virtual host, and also
conn in it will be created balanced to the avarage virtual host load)
but it seems have to work.
Dont remember from where i draged this examples, sorry if any
copyrights :)
http://zdisk.net/pool/conn_pool.txt
http://zdisk.net/pool/conn_pool_eng.txt
http://zdisk.net/pool/conn_sharing.txt
http://zdisk.net/pool/dustman_pool.txt
You can also search mod_python mail list for a conn pooling theme.
And Google.
1) I suppose.
If you use one db connection:
I think conn pooling would give you more gain.
At the end of request conn return back to pool.
If there is no connections on pool they created.
If you try to return to pool conn when it is full -> conn droped.
2) About the server shutdown.
Anyway of you are using pool or not, in my opinion server sutdown
do not have to be more frequient than once a week.
So i can get why you are in so worry about connection close at
shutdown. I can be ignored. Database will close the connection by
timeout anyway, i think that`s not a kind of thing when you know
you are opening 100 connections in a second and say 5-10 not
closed - this is real bad.
Onse a week or say 2 days one connection wont be closed.. so what`s
a big deal?
The thing that is matter - is a database integrity.
I am novice in python and programming :)
Sorry for my english :)
--
Best regards,
Norman mailto:NormanTindall at zdisk.net
|