SlideShare a Scribd company logo
ZODB Tips and Tricks

  Carlos de la Guardia
Most important performance tip

   Find the best size for the ZODB object cache.
   How to calculate best size: take amount of
    available memory and divide by one ;)
   Corollary: Increase RAM as a first step when
    you want better performance.
Looking inside the ZODB

   collective.zodbbrowser is a package that has to
    be installed inside Zope and provides access to
    all objects and their attributes, including
    callables and their source code.
   Eye is an external tool that can be used to
    browse the ZODB without having to install all
    the products it uses.
   You can always use the low-tech approach and
    use the debug mode of an instance to look at
    the values directly using Python.
Oh My God, a POSKey error!

   I feel your pain.
   Unfortunately, getting into the details of how to
    fix this would take a full talk.
   All is not lost, but you'll need to fire up debug
    mode and poke into the internals of your ZODB.
   Before anything else: MAKE A BACKUP!
   Some detailed information here:
    http://plonechix.blogspot.com/2009/12/definitive
    -guide-to-poskeyerror.html
Getting rid of persistent utilities

   Older products that you uninstall sometimes
    can leave persistent utilities installed.
   This will crash your site, because Zope will try
    to import that code.
   There is a package that can help (but
    remember, backup first!):

    http://pypi.python.org/pypi/wildcard.fixpersistent
    utilities/
Recovering objects

   Brute force way: truncate the database
   The civiliced way: use zc.beforestorage
    %import zc.beforestorage
    <before>
      before 2008-12-08T10:29:03
      <filestorage>
         path /zope/var/filestortage/Data.fs
      </filestorage>
    </before>
Searching for transactions

from ZODB.TimeStamp import TimeStamp
from ZODB.FileStorage import FileStorage

storage = FileStorage('/path/to/data.fs', read_only=True)
it = storage.iterator()

earliest = TimeStamp(2010, 2, 26, 6, 0, 0)
# the above is in GMT

for txn in it:
   tid = TimeStamp(txn.tid)
   if tid > earliest:
       print txn.user, txn.description, tid.timeTime(), txn.tid.encode('base64')
       for rec in txn:
          print rec.pos
RelStorage
   A storage implementation for ZODB that stores pickles in a
    relational database.
   It is a drop-in replacement for FileStorage and ZEO.
   Designed for high volume sites: multiple ZODB instances
    can share the same database. This is similar to ZEO, but
    RelStorage does not require ZEO.
   According to some tests, RelStorage handles high
    concurrency better than the standard combination of ZEO
    and FileStorage.
   RelStorage starts quickly regardless of database size.
   Supports undo, packing, and filesystem-based ZODB
    blobs.
   Capable of failover to replicated SQL databases.
Interesting packages

   zodbshootout – benchmark ZEO vs RelStorage
    with different backends
   zodbupdate – update moved or renamed
    classes
   dm.historical – get history of objects in the
    ZODB
   dm.zodb.repair – restore lost objects from a
    backup to a target database
   zc.zodbactivitylog - provides an activity log that
    lets you track database activity
Beginner tips for ZODB development
    Do not use the root to store objects. It doesn't scale.
    Learn about BTrees.
    Avoid storing mutable objects, use persistent sub-
     objects.
    If your objects are bigger than 64k, you need to divide
     them or use blobs.
    Avoid conflicts, organize application threads and data
     structures so that objects are unlikely to be modified
     by multiple threads at the same time.
    Use data structures that support conflict resolution.
    To resolve conflicts, retry. The developer is in charge
     of managing concurrency, not the database.
Tips From the Experts




    I asked some of the old time Zope
developers for some simple tips for using
  the ZODB. Here are their responses.
David Glick

  ”If you want instances of a class to have a new
attribute, add it as a class attribute so that existing
         instances get a reasonable default”
Tips From the Experts




               Lennart Regebro

”Products.ZMIntrospection is quick way to look at
 all the fields of any ZODB object from the ZMI.”
Tips From the Experts


                  Alec Mitchell

”If you need to store arbitrary key/value pairs: use
 PersistentDict when the amount of data is "small"
  and/or you tend to require all the data in a given
transaction; use OOBTree (and friends) when you
   have a large number of keys and tend to only
   need a small subset of them in a transaction.”
Tips From the Experts



                  Alec Mitchell

 ”If you store data in one of the BTree structures
   and you need to count the number of entries,
don't use len(), ever. Use a Btrees.Length object
       to keep track of the count separately.”
Tips From the Experts




                 Alan Runyan

”use zc.zlibstorage for txt heavy databases it's a
    60-70% storage win for those records. ”
zc.zlibstorage

Standalone:                 With ZEO:
%import zc.zlibstorage    %import zc.zlibstorage
<zodb>                    <zeo>
 <zlibstorage>             address 8100
  <filestorage>           </zeo>
   path data.fs           <serverzlibstorage>
  </filestorage>           <filestorage>
 </zlibstorage>             path data.fs
</zodb>                    </filestorage>
                          </serverzlibstorage>
Tips From the Experts



                Alan Runyan

”Use zc.zodbgc, awesome library which provides
inverse graph of ZODB tree so you can see what
           leafs are referneced from”
zc.zodbdgc

   To use zc.zodbdgc just a part to the buildout
    that pulls the egg:

[zodbdgc]
recipe = zc.recipe.egg
eggs = ${instance:eggs}


You can the call the multi-zodb-gc and multi-zodb-
checkrefs.
Tips From the Experts


               Chris McDonough

 ”Use the "BTrees.Length" object to implement
counters in the ZODB. It has conflict resolution
  built in to it that has the potential to eliminate
conflict errors (as opposed to a normal integer
    counter attached to a persistent object).”
Tips From the Experts



                  Tres Seaver

   ”If you find yourself under intense fire, and
everything around you is crumbling, don't despair,
     just increase the ZEO client cache size”
Which cache is which

   Don't confuse the ZEO client cache with the ZODB
    object cache.
   The ZODB object cache stores objects in memory for
    faster responses. You set it with zodb-cache-size in a
    buildout.
   The ZEO client cache is used first when amn object is
    not in the ZODB object cache and avoids round trips
    to the ZEO server. You set it with zeo-client-cache-
    size in a buildout.
   You can enable cache tracing for analysis by setting
    the ZEO_CACHE_TRACE environment variable. More
    information at:
    http://wiki.zope.org/ZODB/trace.html
Tips From the Experts




             Jim Fulton

”Avoid non-persistent mutable objects”
Tips From the Experts




       Jim Fulton

     ”Don't be clever”
Thank You!

         Email: cguardia@yahoo.com

http://zodb.readthedocs.org/en/latest/index.html

More Related Content

What's hot

MongoDB Performance Tuning
MongoDB Performance TuningMongoDB Performance Tuning
MongoDB Performance TuningMongoDB
 
NoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryNoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love Story
Alexandre Morgaut
 
mongoDB Performance
mongoDB PerformancemongoDB Performance
mongoDB PerformanceMoshe Kaplan
 
HotSpotコトハジメ
HotSpotコトハジメHotSpotコトハジメ
HotSpotコトハジメ
Yasumasa Suenaga
 
Leak, lock and a long pause
Leak, lock and a long pauseLeak, lock and a long pause
Leak, lock and a long pause
Julian Warszawski
 
Oscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast LaneOscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast Lane
Andres Almiray
 
Cassandra is great but how do I test my application?
Cassandra is great but how do I test my application?Cassandra is great but how do I test my application?
Cassandra is great but how do I test my application?
Christopher Batey
 
Debugging and Testing ES Systems
Debugging and Testing ES SystemsDebugging and Testing ES Systems
Debugging and Testing ES SystemsChris Birchall
 
greenDAO
greenDAOgreenDAO
greenDAO
Smilee Yang
 
Drools 6 deep dive
Drools 6 deep diveDrools 6 deep dive
Drools 6 deep dive
Mario Fusco
 
MongoDB: tips, trick and hacks
MongoDB: tips, trick and hacksMongoDB: tips, trick and hacks
MongoDB: tips, trick and hacksScott Hernandez
 
MongoDB-SESSION03
MongoDB-SESSION03MongoDB-SESSION03
MongoDB-SESSION03
Jainul Musani
 
Sbt職人のススメ
Sbt職人のススメSbt職人のススメ
Sbt職人のススメ
潤一 加藤
 
Introduction httpClient on Java11 / Java11時代のHTTPアクセス再入門
Introduction httpClient on Java11 / Java11時代のHTTPアクセス再入門Introduction httpClient on Java11 / Java11時代のHTTPアクセス再入門
Introduction httpClient on Java11 / Java11時代のHTTPアクセス再入門
tamtam180
 
Bkbiet day2 & 3
Bkbiet day2 & 3Bkbiet day2 & 3
Bkbiet day2 & 3
mihirio
 
CouchDB Mobile - From Couch to 5K in 1 Hour
CouchDB Mobile - From Couch to 5K in 1 HourCouchDB Mobile - From Couch to 5K in 1 Hour
CouchDB Mobile - From Couch to 5K in 1 Hour
Peter Friese
 
Instroduce Hazelcast
Instroduce HazelcastInstroduce Hazelcast
Instroduce Hazelcastlunfu zhong
 
MongoDB San Francisco DrupalCon 2010
MongoDB San Francisco DrupalCon 2010MongoDB San Francisco DrupalCon 2010
MongoDB San Francisco DrupalCon 2010
Karoly Negyesi
 
Scalable vector ember
Scalable vector emberScalable vector ember
Scalable vector emberMatthew Beale
 
Elasticsearch 설치 및 기본 활용
Elasticsearch 설치 및 기본 활용Elasticsearch 설치 및 기본 활용
Elasticsearch 설치 및 기본 활용
종민 김
 

What's hot (20)

MongoDB Performance Tuning
MongoDB Performance TuningMongoDB Performance Tuning
MongoDB Performance Tuning
 
NoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryNoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love Story
 
mongoDB Performance
mongoDB PerformancemongoDB Performance
mongoDB Performance
 
HotSpotコトハジメ
HotSpotコトハジメHotSpotコトハジメ
HotSpotコトハジメ
 
Leak, lock and a long pause
Leak, lock and a long pauseLeak, lock and a long pause
Leak, lock and a long pause
 
Oscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast LaneOscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast Lane
 
Cassandra is great but how do I test my application?
Cassandra is great but how do I test my application?Cassandra is great but how do I test my application?
Cassandra is great but how do I test my application?
 
Debugging and Testing ES Systems
Debugging and Testing ES SystemsDebugging and Testing ES Systems
Debugging and Testing ES Systems
 
greenDAO
greenDAOgreenDAO
greenDAO
 
Drools 6 deep dive
Drools 6 deep diveDrools 6 deep dive
Drools 6 deep dive
 
MongoDB: tips, trick and hacks
MongoDB: tips, trick and hacksMongoDB: tips, trick and hacks
MongoDB: tips, trick and hacks
 
MongoDB-SESSION03
MongoDB-SESSION03MongoDB-SESSION03
MongoDB-SESSION03
 
Sbt職人のススメ
Sbt職人のススメSbt職人のススメ
Sbt職人のススメ
 
Introduction httpClient on Java11 / Java11時代のHTTPアクセス再入門
Introduction httpClient on Java11 / Java11時代のHTTPアクセス再入門Introduction httpClient on Java11 / Java11時代のHTTPアクセス再入門
Introduction httpClient on Java11 / Java11時代のHTTPアクセス再入門
 
Bkbiet day2 & 3
Bkbiet day2 & 3Bkbiet day2 & 3
Bkbiet day2 & 3
 
CouchDB Mobile - From Couch to 5K in 1 Hour
CouchDB Mobile - From Couch to 5K in 1 HourCouchDB Mobile - From Couch to 5K in 1 Hour
CouchDB Mobile - From Couch to 5K in 1 Hour
 
Instroduce Hazelcast
Instroduce HazelcastInstroduce Hazelcast
Instroduce Hazelcast
 
MongoDB San Francisco DrupalCon 2010
MongoDB San Francisco DrupalCon 2010MongoDB San Francisco DrupalCon 2010
MongoDB San Francisco DrupalCon 2010
 
Scalable vector ember
Scalable vector emberScalable vector ember
Scalable vector ember
 
Elasticsearch 설치 및 기본 활용
Elasticsearch 설치 및 기본 활용Elasticsearch 설치 및 기본 활용
Elasticsearch 설치 및 기본 활용
 

Similar to ZODB Tips and Tricks

node.js 실무 - node js in practice by Jesang Yoon
node.js 실무 - node js in practice by Jesang Yoonnode.js 실무 - node js in practice by Jesang Yoon
node.js 실무 - node js in practice by Jesang Yoon
Jesang Yoon
 
Cloud Best Practices
Cloud Best PracticesCloud Best Practices
Cloud Best PracticesEric Bottard
 
Python mongo db-training-europython-2011
Python mongo db-training-europython-2011Python mongo db-training-europython-2011
Python mongo db-training-europython-2011
Andreas Jung
 
Perl and Elasticsearch
Perl and ElasticsearchPerl and Elasticsearch
Perl and Elasticsearch
Dean Hamstead
 
Pse2010 rel storage
Pse2010 rel storagePse2010 rel storage
Pse2010 rel storageLars Noldan
 
Intro to BackboneJS + Intermediate Javascript
Intro to BackboneJS + Intermediate JavascriptIntro to BackboneJS + Intermediate Javascript
Intro to BackboneJS + Intermediate JavascriptAndrew Lovett-Barron
 
Lessons Learned Migrating 2+ Billion Documents at Craigslist
Lessons Learned Migrating 2+ Billion Documents at CraigslistLessons Learned Migrating 2+ Billion Documents at Craigslist
Lessons Learned Migrating 2+ Billion Documents at Craigslist
Jeremy Zawodny
 
SFDX – Myth Buster, Svatopluk Sejkora
SFDX – Myth Buster, Svatopluk SejkoraSFDX – Myth Buster, Svatopluk Sejkora
SFDX – Myth Buster, Svatopluk Sejkora
CzechDreamin
 
MongoDB Pros and Cons
MongoDB Pros and ConsMongoDB Pros and Cons
MongoDB Pros and Cons
johnrjenson
 
Monitoring Oracle Database Instances with Zabbix
Monitoring Oracle Database Instances with ZabbixMonitoring Oracle Database Instances with Zabbix
Monitoring Oracle Database Instances with Zabbix
Gerger
 
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
Performance Tuning -  Memory leaks, Thread deadlocks, JDK toolsPerformance Tuning -  Memory leaks, Thread deadlocks, JDK tools
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
Haribabu Nandyal Padmanaban
 
Toro DB- Open-source, MongoDB-compatible database, built on top of PostgreSQL
Toro DB- Open-source, MongoDB-compatible database,  built on top of PostgreSQLToro DB- Open-source, MongoDB-compatible database,  built on top of PostgreSQL
Toro DB- Open-source, MongoDB-compatible database, built on top of PostgreSQL
InMobi Technology
 
GWT is Smarter Than You
GWT is Smarter Than YouGWT is Smarter Than You
GWT is Smarter Than You
Robert Cooper
 
2019 PHP Serbia - Boosting your performance with Blackfire
2019 PHP Serbia - Boosting your performance with Blackfire2019 PHP Serbia - Boosting your performance with Blackfire
2019 PHP Serbia - Boosting your performance with Blackfire
Marko Mitranić
 
Dojo: Getting Started Today
Dojo: Getting Started TodayDojo: Getting Started Today
Dojo: Getting Started Today
Gabriel Hamilton
 
Why databases cry at night
Why databases cry at nightWhy databases cry at night
Why databases cry at night
Michael Yarichuk
 
Zend framework 03 - singleton factory data mapper caching logging
Zend framework 03 - singleton factory data mapper caching loggingZend framework 03 - singleton factory data mapper caching logging
Zend framework 03 - singleton factory data mapper caching logging
Tricode (part of Dept)
 
Operating and Supporting Delta Lake in Production
Operating and Supporting Delta Lake in ProductionOperating and Supporting Delta Lake in Production
Operating and Supporting Delta Lake in Production
Databricks
 
I know why your Java is slow
I know why your Java is slowI know why your Java is slow
I know why your Java is slow
aragozin
 

Similar to ZODB Tips and Tricks (20)

node.js 실무 - node js in practice by Jesang Yoon
node.js 실무 - node js in practice by Jesang Yoonnode.js 실무 - node js in practice by Jesang Yoon
node.js 실무 - node js in practice by Jesang Yoon
 
Cloud Best Practices
Cloud Best PracticesCloud Best Practices
Cloud Best Practices
 
Python mongo db-training-europython-2011
Python mongo db-training-europython-2011Python mongo db-training-europython-2011
Python mongo db-training-europython-2011
 
Perl and Elasticsearch
Perl and ElasticsearchPerl and Elasticsearch
Perl and Elasticsearch
 
Pse2010 rel storage
Pse2010 rel storagePse2010 rel storage
Pse2010 rel storage
 
Intro to BackboneJS + Intermediate Javascript
Intro to BackboneJS + Intermediate JavascriptIntro to BackboneJS + Intermediate Javascript
Intro to BackboneJS + Intermediate Javascript
 
Lessons Learned Migrating 2+ Billion Documents at Craigslist
Lessons Learned Migrating 2+ Billion Documents at CraigslistLessons Learned Migrating 2+ Billion Documents at Craigslist
Lessons Learned Migrating 2+ Billion Documents at Craigslist
 
SFDX – Myth Buster, Svatopluk Sejkora
SFDX – Myth Buster, Svatopluk SejkoraSFDX – Myth Buster, Svatopluk Sejkora
SFDX – Myth Buster, Svatopluk Sejkora
 
MongoDB Pros and Cons
MongoDB Pros and ConsMongoDB Pros and Cons
MongoDB Pros and Cons
 
Monitoring Oracle Database Instances with Zabbix
Monitoring Oracle Database Instances with ZabbixMonitoring Oracle Database Instances with Zabbix
Monitoring Oracle Database Instances with Zabbix
 
10 Ways To Improve Your Code
10 Ways To Improve Your Code10 Ways To Improve Your Code
10 Ways To Improve Your Code
 
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
Performance Tuning -  Memory leaks, Thread deadlocks, JDK toolsPerformance Tuning -  Memory leaks, Thread deadlocks, JDK tools
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
 
Toro DB- Open-source, MongoDB-compatible database, built on top of PostgreSQL
Toro DB- Open-source, MongoDB-compatible database,  built on top of PostgreSQLToro DB- Open-source, MongoDB-compatible database,  built on top of PostgreSQL
Toro DB- Open-source, MongoDB-compatible database, built on top of PostgreSQL
 
GWT is Smarter Than You
GWT is Smarter Than YouGWT is Smarter Than You
GWT is Smarter Than You
 
2019 PHP Serbia - Boosting your performance with Blackfire
2019 PHP Serbia - Boosting your performance with Blackfire2019 PHP Serbia - Boosting your performance with Blackfire
2019 PHP Serbia - Boosting your performance with Blackfire
 
Dojo: Getting Started Today
Dojo: Getting Started TodayDojo: Getting Started Today
Dojo: Getting Started Today
 
Why databases cry at night
Why databases cry at nightWhy databases cry at night
Why databases cry at night
 
Zend framework 03 - singleton factory data mapper caching logging
Zend framework 03 - singleton factory data mapper caching loggingZend framework 03 - singleton factory data mapper caching logging
Zend framework 03 - singleton factory data mapper caching logging
 
Operating and Supporting Delta Lake in Production
Operating and Supporting Delta Lake in ProductionOperating and Supporting Delta Lake in Production
Operating and Supporting Delta Lake in Production
 
I know why your Java is slow
I know why your Java is slowI know why your Java is slow
I know why your Java is slow
 

More from Jazkarta, Inc.

Traveling through time and place with Plone
Traveling through time and place with PloneTraveling through time and place with Plone
Traveling through time and place with Plone
Jazkarta, Inc.
 
Questions: A Form Library for Python with SurveyJS Frontend
Questions: A Form Library for Python with SurveyJS FrontendQuestions: A Form Library for Python with SurveyJS Frontend
Questions: A Form Library for Python with SurveyJS Frontend
Jazkarta, Inc.
 
The User Experience: Editing Composite Pages in Plone 6 and Beyond
The User Experience: Editing Composite Pages in Plone 6 and BeyondThe User Experience: Editing Composite Pages in Plone 6 and Beyond
The User Experience: Editing Composite Pages in Plone 6 and Beyond
Jazkarta, Inc.
 
WTA and Plone After 13 Years
WTA and Plone After 13 YearsWTA and Plone After 13 Years
WTA and Plone After 13 Years
Jazkarta, Inc.
 
Collaborating With Orchid Data
Collaborating With Orchid DataCollaborating With Orchid Data
Collaborating With Orchid Data
Jazkarta, Inc.
 
Spend a Week Hacking in Sorrento!
Spend a Week Hacking in Sorrento!Spend a Week Hacking in Sorrento!
Spend a Week Hacking in Sorrento!
Jazkarta, Inc.
 
Plone 5 Upgrades In Real Life
Plone 5 Upgrades In Real LifePlone 5 Upgrades In Real Life
Plone 5 Upgrades In Real Life
Jazkarta, Inc.
 
Accessibility in Plone: The Good, the Bad, and the Ugly
Accessibility in Plone: The Good, the Bad, and the UglyAccessibility in Plone: The Good, the Bad, and the Ugly
Accessibility in Plone: The Good, the Bad, and the Ugly
Jazkarta, Inc.
 
Getting Paid Without GetPaid
Getting Paid Without GetPaidGetting Paid Without GetPaid
Getting Paid Without GetPaid
Jazkarta, Inc.
 
An Open Source Platform for Social Science Research
An Open Source Platform for Social Science ResearchAn Open Source Platform for Social Science Research
An Open Source Platform for Social Science Research
Jazkarta, Inc.
 
For the Love of Volunteers! How Do You Choose the Right Technology to Manage ...
For the Love of Volunteers! How Do You Choose the Right Technology to Manage ...For the Love of Volunteers! How Do You Choose the Right Technology to Manage ...
For the Love of Volunteers! How Do You Choose the Right Technology to Manage ...
Jazkarta, Inc.
 
Anatomy of a Large Website Project
Anatomy of a Large Website ProjectAnatomy of a Large Website Project
Anatomy of a Large Website Project
Jazkarta, Inc.
 
Anatomy of a Large Website Project - With Presenter Notes
Anatomy of a Large Website Project - With Presenter NotesAnatomy of a Large Website Project - With Presenter Notes
Anatomy of a Large Website Project - With Presenter Notes
Jazkarta, Inc.
 
The Mountaineers: Scaling the Heights with Plone
The Mountaineers: Scaling the Heights with PloneThe Mountaineers: Scaling the Heights with Plone
The Mountaineers: Scaling the Heights with Plone
Jazkarta, Inc.
 
Plone Hosting: A Panel Discussion
Plone Hosting: A Panel DiscussionPlone Hosting: A Panel Discussion
Plone Hosting: A Panel Discussion
Jazkarta, Inc.
 
Plone+Salesforce
Plone+SalesforcePlone+Salesforce
Plone+Salesforce
Jazkarta, Inc.
 
Academic Websites in Plone
Academic Websites in PloneAcademic Websites in Plone
Academic Websites in PloneJazkarta, Inc.
 
Plone
PlonePlone
Online Exhibits in Plone
Online Exhibits in PloneOnline Exhibits in Plone
Online Exhibits in Plone
Jazkarta, Inc.
 
Online exhibits in Plone
Online exhibits in PloneOnline exhibits in Plone
Online exhibits in Plone
Jazkarta, Inc.
 

More from Jazkarta, Inc. (20)

Traveling through time and place with Plone
Traveling through time and place with PloneTraveling through time and place with Plone
Traveling through time and place with Plone
 
Questions: A Form Library for Python with SurveyJS Frontend
Questions: A Form Library for Python with SurveyJS FrontendQuestions: A Form Library for Python with SurveyJS Frontend
Questions: A Form Library for Python with SurveyJS Frontend
 
The User Experience: Editing Composite Pages in Plone 6 and Beyond
The User Experience: Editing Composite Pages in Plone 6 and BeyondThe User Experience: Editing Composite Pages in Plone 6 and Beyond
The User Experience: Editing Composite Pages in Plone 6 and Beyond
 
WTA and Plone After 13 Years
WTA and Plone After 13 YearsWTA and Plone After 13 Years
WTA and Plone After 13 Years
 
Collaborating With Orchid Data
Collaborating With Orchid DataCollaborating With Orchid Data
Collaborating With Orchid Data
 
Spend a Week Hacking in Sorrento!
Spend a Week Hacking in Sorrento!Spend a Week Hacking in Sorrento!
Spend a Week Hacking in Sorrento!
 
Plone 5 Upgrades In Real Life
Plone 5 Upgrades In Real LifePlone 5 Upgrades In Real Life
Plone 5 Upgrades In Real Life
 
Accessibility in Plone: The Good, the Bad, and the Ugly
Accessibility in Plone: The Good, the Bad, and the UglyAccessibility in Plone: The Good, the Bad, and the Ugly
Accessibility in Plone: The Good, the Bad, and the Ugly
 
Getting Paid Without GetPaid
Getting Paid Without GetPaidGetting Paid Without GetPaid
Getting Paid Without GetPaid
 
An Open Source Platform for Social Science Research
An Open Source Platform for Social Science ResearchAn Open Source Platform for Social Science Research
An Open Source Platform for Social Science Research
 
For the Love of Volunteers! How Do You Choose the Right Technology to Manage ...
For the Love of Volunteers! How Do You Choose the Right Technology to Manage ...For the Love of Volunteers! How Do You Choose the Right Technology to Manage ...
For the Love of Volunteers! How Do You Choose the Right Technology to Manage ...
 
Anatomy of a Large Website Project
Anatomy of a Large Website ProjectAnatomy of a Large Website Project
Anatomy of a Large Website Project
 
Anatomy of a Large Website Project - With Presenter Notes
Anatomy of a Large Website Project - With Presenter NotesAnatomy of a Large Website Project - With Presenter Notes
Anatomy of a Large Website Project - With Presenter Notes
 
The Mountaineers: Scaling the Heights with Plone
The Mountaineers: Scaling the Heights with PloneThe Mountaineers: Scaling the Heights with Plone
The Mountaineers: Scaling the Heights with Plone
 
Plone Hosting: A Panel Discussion
Plone Hosting: A Panel DiscussionPlone Hosting: A Panel Discussion
Plone Hosting: A Panel Discussion
 
Plone+Salesforce
Plone+SalesforcePlone+Salesforce
Plone+Salesforce
 
Academic Websites in Plone
Academic Websites in PloneAcademic Websites in Plone
Academic Websites in Plone
 
Plone
PlonePlone
Plone
 
Online Exhibits in Plone
Online Exhibits in PloneOnline Exhibits in Plone
Online Exhibits in Plone
 
Online exhibits in Plone
Online exhibits in PloneOnline exhibits in Plone
Online exhibits in Plone
 

Recently uploaded

FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 

Recently uploaded (20)

FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 

ZODB Tips and Tricks

  • 1. ZODB Tips and Tricks Carlos de la Guardia
  • 2. Most important performance tip  Find the best size for the ZODB object cache.  How to calculate best size: take amount of available memory and divide by one ;)  Corollary: Increase RAM as a first step when you want better performance.
  • 3. Looking inside the ZODB  collective.zodbbrowser is a package that has to be installed inside Zope and provides access to all objects and their attributes, including callables and their source code.  Eye is an external tool that can be used to browse the ZODB without having to install all the products it uses.  You can always use the low-tech approach and use the debug mode of an instance to look at the values directly using Python.
  • 4. Oh My God, a POSKey error!  I feel your pain.  Unfortunately, getting into the details of how to fix this would take a full talk.  All is not lost, but you'll need to fire up debug mode and poke into the internals of your ZODB.  Before anything else: MAKE A BACKUP!  Some detailed information here: http://plonechix.blogspot.com/2009/12/definitive -guide-to-poskeyerror.html
  • 5. Getting rid of persistent utilities  Older products that you uninstall sometimes can leave persistent utilities installed.  This will crash your site, because Zope will try to import that code.  There is a package that can help (but remember, backup first!): http://pypi.python.org/pypi/wildcard.fixpersistent utilities/
  • 6. Recovering objects  Brute force way: truncate the database  The civiliced way: use zc.beforestorage %import zc.beforestorage <before> before 2008-12-08T10:29:03 <filestorage> path /zope/var/filestortage/Data.fs </filestorage> </before>
  • 7. Searching for transactions from ZODB.TimeStamp import TimeStamp from ZODB.FileStorage import FileStorage storage = FileStorage('/path/to/data.fs', read_only=True) it = storage.iterator() earliest = TimeStamp(2010, 2, 26, 6, 0, 0) # the above is in GMT for txn in it: tid = TimeStamp(txn.tid) if tid > earliest: print txn.user, txn.description, tid.timeTime(), txn.tid.encode('base64') for rec in txn: print rec.pos
  • 8. RelStorage  A storage implementation for ZODB that stores pickles in a relational database.  It is a drop-in replacement for FileStorage and ZEO.  Designed for high volume sites: multiple ZODB instances can share the same database. This is similar to ZEO, but RelStorage does not require ZEO.  According to some tests, RelStorage handles high concurrency better than the standard combination of ZEO and FileStorage.  RelStorage starts quickly regardless of database size.  Supports undo, packing, and filesystem-based ZODB blobs.  Capable of failover to replicated SQL databases.
  • 9. Interesting packages  zodbshootout – benchmark ZEO vs RelStorage with different backends  zodbupdate – update moved or renamed classes  dm.historical – get history of objects in the ZODB  dm.zodb.repair – restore lost objects from a backup to a target database  zc.zodbactivitylog - provides an activity log that lets you track database activity
  • 10. Beginner tips for ZODB development  Do not use the root to store objects. It doesn't scale.  Learn about BTrees.  Avoid storing mutable objects, use persistent sub- objects.  If your objects are bigger than 64k, you need to divide them or use blobs.  Avoid conflicts, organize application threads and data structures so that objects are unlikely to be modified by multiple threads at the same time.  Use data structures that support conflict resolution.  To resolve conflicts, retry. The developer is in charge of managing concurrency, not the database.
  • 11. Tips From the Experts I asked some of the old time Zope developers for some simple tips for using the ZODB. Here are their responses.
  • 12. David Glick ”If you want instances of a class to have a new attribute, add it as a class attribute so that existing instances get a reasonable default”
  • 13. Tips From the Experts Lennart Regebro ”Products.ZMIntrospection is quick way to look at all the fields of any ZODB object from the ZMI.”
  • 14. Tips From the Experts Alec Mitchell ”If you need to store arbitrary key/value pairs: use PersistentDict when the amount of data is "small" and/or you tend to require all the data in a given transaction; use OOBTree (and friends) when you have a large number of keys and tend to only need a small subset of them in a transaction.”
  • 15. Tips From the Experts Alec Mitchell ”If you store data in one of the BTree structures and you need to count the number of entries, don't use len(), ever. Use a Btrees.Length object to keep track of the count separately.”
  • 16. Tips From the Experts Alan Runyan ”use zc.zlibstorage for txt heavy databases it's a 60-70% storage win for those records. ”
  • 17. zc.zlibstorage Standalone: With ZEO: %import zc.zlibstorage %import zc.zlibstorage <zodb> <zeo> <zlibstorage> address 8100 <filestorage> </zeo> path data.fs <serverzlibstorage> </filestorage> <filestorage> </zlibstorage> path data.fs </zodb> </filestorage> </serverzlibstorage>
  • 18. Tips From the Experts Alan Runyan ”Use zc.zodbgc, awesome library which provides inverse graph of ZODB tree so you can see what leafs are referneced from”
  • 19. zc.zodbdgc  To use zc.zodbdgc just a part to the buildout that pulls the egg: [zodbdgc] recipe = zc.recipe.egg eggs = ${instance:eggs} You can the call the multi-zodb-gc and multi-zodb- checkrefs.
  • 20. Tips From the Experts Chris McDonough ”Use the "BTrees.Length" object to implement counters in the ZODB. It has conflict resolution built in to it that has the potential to eliminate conflict errors (as opposed to a normal integer counter attached to a persistent object).”
  • 21. Tips From the Experts Tres Seaver ”If you find yourself under intense fire, and everything around you is crumbling, don't despair, just increase the ZEO client cache size”
  • 22. Which cache is which  Don't confuse the ZEO client cache with the ZODB object cache.  The ZODB object cache stores objects in memory for faster responses. You set it with zodb-cache-size in a buildout.  The ZEO client cache is used first when amn object is not in the ZODB object cache and avoids round trips to the ZEO server. You set it with zeo-client-cache- size in a buildout.  You can enable cache tracing for analysis by setting the ZEO_CACHE_TRACE environment variable. More information at: http://wiki.zope.org/ZODB/trace.html
  • 23. Tips From the Experts Jim Fulton ”Avoid non-persistent mutable objects”
  • 24. Tips From the Experts Jim Fulton ”Don't be clever”
  • 25. Thank You! Email: cguardia@yahoo.com http://zodb.readthedocs.org/en/latest/index.html