[Zope3-Users] ZODB conflict for session data container

Bernd Dorn bernd.dorn at lovelysystems.com
Thu Mar 20 03:45:56 EDT 2008


On 20.03.2008, at 07:07, Yuan HOng wrote:
> Now comes the part that I can not understand. This simultaneous adding
> to the BTree seem to cause the conflict error, since the BTree and
> Bucket are also persistent object themselves. This would mean that
> ZODB is not suitable for the cases of simultanous adding to a BTree by
> multiple threads, like in my case for session data.
>

exactly

> But since ZODB and zope.session are so widely used, I can not image
> that this could be the case, otherwise how can anyone be reliably
> using ZODB for session? So I must be missing some very important
> points.


it is the case ... there are two workarounds imho

1.
don't write to the session if it does not change, so if you do an  
apache bench without sending the client id cookie, a write is done on  
each request

additionally every anonymous visit writes to zodb, you should avoid  
this by using default values if no session data is available

in earlier versions of zope the __getitem__ method created a btree at  
first access, but this should be fixed now, so it depends on the  
version of zope u use, if you have an older version then you can't  
even look if data is there without writing to zodb

2.
my recommendation is to use memcached for session data ... take a look  
at http://svn.zope.org/repos/main/lovely.memcached/trunk

regards, bernd


-- 
Lovely Systems, senior developer

phone: +43 5572 908060, fax: +43 5572 908060-77
Schmelzhütterstraße 26a, 6850 Dornbirn, Austria
skype: bernd.dorn



-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2548 bytes
Desc: not available
Url : http://mail.zope.org/pipermail/zope3-users/attachments/20080320/078154be/smime.bin


More information about the Zope3-users mailing list