CRX and Tar PM

Thomas Müller has a blog post that nicely describes how the Tar PM works. Tar PM is the fastest of Day CRX’s pluggable persistence managers. The speed of Tar PM is a major reason why some companies go with the CRX rather than the free JCR reference implementation Apache JackRabbit.

The key to Tar PM’s speed is that it only supports write operations and these operations just append the new data to the end of one big file (a TAR file actually). What content objects are stored where is recorded in an index which is also read-only. To prevent limitless growth of the data file, you need to periodically run maintenance programs that compress the file be removing deleted records.

This may seem very familiar to those of you who have managed systems built on Zope (like Plone) and have had to “pack the database” – an operation that does essentially the same thing as the CRX tools plus remove unneeded intermediate versions that were defensively saved during transactions. From my experience with Zope, I know that having a huge, single file database can be scary but not necessarily dangerous. What do you do if you have a corrupt record in the middle of the file that causes the maintenance tools to crash? Usually there is some way to fix it but you need access to the experts. The only issue is that Zope and CRX experts are not as easily found as Oracle, MySQL, or MSSQL experts. Tar PM seems to improve on the ZODB by switching to a new TAR file after a certain point. Longtime readers of this blog may remember my ZOracle Series (part I, II, and III) that described a project to point the Zope Object Database (ZODB) to an Oracle database.

Although both Zope and Day have customers with huge repositories, the general rule of thumb is to keep things small when you can. In the ZODB world there are extensions that store large binary files outside of the database. In the JCR world, the strategy is to segment content into smaller repositories. For example, if you have lots of publications, put each one into its own JCR instance rather that combine them all into one. Companies that pursue this type of segmentation need to have some component in the architecture that can look across repositories and maintain collections of references to show an aggregated view. At the simplest level, this can be a search engine. At a more advanced level there could be hierarchical taxonomy system with references to items in different repositories.

This strategy runs against Oracle’s vision of all your company’s content neatly organized in one big database. I would argue that putting everything in one place does not necessarily mean that it is well managed or easy to find. More important than how the content is physically stored is that it is cohesively organized (that is, content that belongs together is stored together) and that there are uniform ways to access it. This is the strategy of the JCR and it plays well with service oriented architecture where different applications (services) that manage their own data can be combined to support cross-application business processes. When you have everything in the same database, the tendency is to do your integration at the data level (which can be brittle and proprietary) rather than the application (or service) level. I won’t deny that it is handy to have a database that can scale infinitely in size and there are applications that need very large storage (like archival systems). But trying to keep things small and segmented has its virtues as well. I am reminded of the frequently made point that storage is cheap but finding and managing the information can be very expensive.

  • Deane

    Regarding the ZODB, this is one of the things that continues to scare people away from that platform. With Zope, you have a system that comes with its own Web server and database server. This is not the way to set the mind of a new developer at ease.

    The freakout factor with this strategy is huge, and I’m sure it negatively affects their penetration.

  • Jack

    Well, thats the difference between a new developer and an experienced java developer. This is a fantastic strategy which is easy to migrate over to as well as easy to promote nodes by simply copying the tar files. Great idea!

  • James Stansell

    In the JCR world, the strategy is to segment content into smaller repositories. For example, if you have lots of publications, put each one into its own JCR instance rather that combine them all into one.

    My company currently has a single JCR instance which we are preparing to populate with dozens of publications.

    Do you have any references for this “separate instance” strategy? Examples would also be great too!

    Thanks,

    -james.

  • Seth

    Hi James,

    I am doing some work for a major US-based magazine publisher that has one JCR repository per title. That said, they have segmented their content ID ranges to keep open the possibility of merging at a later date. They went to this strategy after they saw degrading performance as the repository grew. Also they didn’t want their maintenance scripts to take too long.

  • David Nuescheler

    Hi Seth,

    thanks a lot for the write-up.

    I generally think that there are a couple of interesting points to be observed.

    First and foremost it is important that every customer is free to choose in CRX between a traditional RDBMS persistence (where of course all the major DB vendors are supported) and the TarPM.
    And I completely agree with you that customers that have an experienced DBA team, but do not have Filesystem experience (for example already have SAN & NAS infrastructure) should definitely choose what they are comfortable with from an infrastructure perspective, operational stability clearly outweighs performance gains.

    While the TarPM's performance certainly is a very appealing feature that yields write performance gains by factors, it is in my experience not the single driving feature for choosing CRX over Jackrabbit. I would like to mention things like Service Level Agreements, ease of clustering, hot backup, built-in Web caching or just simply production level resilience as well as application level features.

    The most important differentiation of TarPM to any other means of persistence (like an Oracle DB) is that it specifically does not choose a proprietary persistence but chooses a well known file format, that a very broad group of people can handle. We are essentially just talking about a rolling set of tar files with fixed a fixed size each.
    In this sense the TarPM is fundamentally different from any other (relational and non-relational) database.

    While there maybe people that understand the underlying persistence of an oracle database at a great level of detail, there are definitely more people that understand and can handle a Tar file in case they for example would need to go in there and validate transactions or even do something simple like rolling back to a particular state.

    I think it is also important that Thomas' background is really an RDBMS background developing both HSQLDB and H2 which I consider the
    best and fastest embedded Java Database.
    http://www.ohloh.net/accounts/ThomasMueller

    Thanks again for discussing the TarPM as we are very excited about it and see it as fundamentally different from any other proprietary or commercial database
    I really enjoy having these conversations.

    regards,
    david

  • Thomas Mueller

    Hi,

    great article! Some remarks about the Tar PM and CRX:

    > To prevent limitless growth.., you need to periodically run maintenance programs..

    In the upcoming release this will be fully automated by default (in the current version you can automate it, but it is not done by default).

    > In the JCR world, the strategy is to segment content into smaller repositories.

    For CRX, you can put everything in one repository. Technically it's not a problem. For some scenarios it may make sense to segment the content of course, for example into workspaces.

    > In the ZODB world there are extensions that store large binary files outside of the database.

    That sounds like the CRX 'data store'. To save space, large objects are only stored once. The generic term for this concept is 'content-addressable storage' by the way.

  • Mark

    Does the maintenance performed on the tar files to defragment and compress the data store impact repository performance or disable or delay content access in any way?

    • http://www.contenthere.net seth

      I can’t speak for TAR PM but I know that a ZODB “pack” does slow down system performance. My client that was using the CRX and TAR PM has a static publishing model where HTML files are pushed out to a farm of web servers so web traffic never hit the JCR. TAR maintenance was done outside of business hours to avoid contributor load.