If using PostgreSQL, take a look at pgpool or pgbouncer, they will do
some of the things you're expecting, without modifing a single line of
web2py (keep pool_size=1).

Regards

Mariano Reingart
http://www.sistemasagiles.com.ar
http://reingart.blogspot.com



On Mon, Sep 27, 2010 at 9:48 PM, mdipierro <[email protected]> wrote:
> I would not know how to do this. If you have a lot of users (say 1000)
> how do you know when to close a connection? Do you keep all of them
> open?
>
> On Sep 27, 3:25 pm, Josh J <[email protected]> wrote:
>> Most applications connect to the database with one set of credentials,
>> regardless of the user accessing the pages. The current pooling model
>> works very well in this situation.
>>
>> My application must implement per-user connections to the database,
>> where each user will have their own credentials for the database.
>>
>> It is simple enough to have web2py to establish a connection on each
>> page load for the users, the difficulty lies with leaving persistent
>> connections open between page loads. The simplest way I have found to
>> do this is by making a SQLDB with pool_size=1 for each user.  The
>> problem with this method is that the users connection will stay open
>> after they logout.
>>
>> I know it's possible to manage the connection pool by manipulating
>> SQLDB._connection_pools externally from my app (say in
>> auth.settings.logout_onlogout), however I would prefer to do something
>> that I know won't break with future updates.
>>
>> So, community, I ask you, how should I be implementing per-user
>> persistent database connections with web2py?

Reply via email to