1 / 19

Prevayler

Prevayler. Agenda. Introduction Object Prevalence Concepts Prevayler Concepts Transaction processing Performance Conclusion. Introduction. Persistence layer of business applications Typical: Usage of an RDBMS a nd O/R-Mapping Bridging between object model and relational model

berit
Download Presentation

Prevayler

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Prevayler

  2. Agenda • Introduction • Object Prevalence • Concepts • Prevayler • Concepts • Transaction processing • Performance • Conclusion

  3. Introduction • Persistence layer of business applications • Typical: Usage of an RDBMS and O/R-Mapping • Bridging between object model and relational model • Mapping mostly not transparent • Mapping expensive • Ideal: • Transparent persistency • Business objects... • having ACID semantics • implementation matchestransient implementation No mapping between data models rapid development quick prototyping possible

  4. Object Prevalence • Concept first published in 1987 by A. D. Birrell, M. B. Jones und E. P. Wobber in ‘A Simple and Efficient Implementation for Small Databases‘ • Pattern for keeping in-memory data structures durable • Later named‘Object Prevalence‘by Klaus Wuestefeld • Founder of the Prevayler project

  5. Object Prevalence • Core Concepts • All data organized in single data structure • Data structure held in memory • Premises: • System has plenty of memory to hold all data • Price of memory keeps dropping • No shortage of address space due to VM and 64 bit  Data available to owning process only • Contrary to RDBMS – RDBMS designed not to have all data in memory

  6. Object Prevalence • Core Concepts (2) • Periodicsnapshot of data structure • Saved on durable medium (hard disk) • Data structure accessed indirectly • Command-Pattern • Write Ahead Log for modifying accesses • Log documents all modifications since last snapshot • Saved on durable medium (hard disk) • Startup/Recovery • Read recent snapshot • Playback log

  7. Prevayler • Project Prevayler • Foundedby Klaus Wuestefeld • First public implementation of Object Prevalence • First universal implementation • Written in Java • Open Source (BSD Lizense) • First release in 2001 (LGPL) • Meanwhile, further Object Prevalence implementations exist • Gained publicity by performance claims • 9000 times faster than Oracle (über JDBC) • 3000 times faster than MySQL (über JDBC) • ... but no TPC-C available

  8. Prevayler – Concepts • Data structure • Tree of Java objects • Contains all business objects • All objects must be accessible by a single root • Root object named ‘Prevalent System‘ • All objects must be serializable • Implementation of java.io.Serializable or java.io.Externalizable  required for taking snaphots

  9. Prevayler – Concepts • Data access • Indirect access thru command objects • Readonly: Query-object • Modifications: Transaction-object • Only programmatic access • No Query Language • Commands are opaque to Prevayler • Prevayler cannot determineactual modifcations made • Synchronisation must be performedon Data structure level • Much more coarse-grained than RDBMS (page level)

  10. Prevayler – Concepts • Data access (2) • Query/Transaction execution • Before execution, lock on data structure must be aquired • No reader/writer lock distinction • Serial execution of all commands • Readonly Access • Implementation of Query-Interface • Commands not written to log  Query-objects must not perform any modifications public interface Query { public Object query( Object prevalentSystem, Date executionTime) throws Exception; }

  11. Prevayler – Concepts • Data access (3) • Modifying Access • Implementation of Transaction/TransactionWithQuery-Interface • Object must be serializable • Will be serialized to command log before execution • Deterministic behaviour • Replay during Startup/Recovery phase • External resources should not be used • (historic) Prevayler-time must be used instead of system time public interface Transaction extends java.io.Serializable { publicvoid executeOn( Object prevalentSystem, Date executionTime); }

  12. Prevayler – Data safety • Snapshots • Serialization of complete object tree • Standard: Java Object Serialization • All objects are serialized, not only ‚dirty‘ objects • Performed periodically • Process • Acquire lock on object tree • Serialize tree into file • Release lock • Mark snapshot file as complete • Truncate command log, delete old snapshot (optional) • Process may take several minutes  Downtime • Can be avoided by using a replica

  13. Prevayler – Data safety • Transaction processing • Process • Serializability-Test of command object • Approval by Censor • Adding entry to Transaction Log • Call Transaction.executeOn() • Execution of Transaction-Command considered atomic • But: Atomicity must be assured by developer • On error, all modifications must be rolled back manually  Complex for non-trivial commands • Transaction.executeOn may throw an exception • Result depends on Censor used

  14. Prevayler – Data safety • Transaction processing– Censors (2) • Censors • ‚Approve‘ Commands before their execution • Are optional • StrictTransactionCensor • Command executed twice • Execution on copy of data structure (‘Food Taster‘) • If successful: • Execution on main data strcture • If an error occured (Exception): • Transaction is aborted • Recovery of ‘Food Taster‘ •  Costly operation • Consequences • Failing commands may leave data structure in inconsistent state • Inconsistencies less likely though • Increased memory usage and execution time

  15. Prevayler – Data safety • ACID • Snapshots and logs ensure durability • Serial command execution implies Isolation • Developer is responsible of atomicity • Commands must be implememnted in atomic fashion • May be achived by using compensating actions • Developer has to ensure consistency of data structure • Object tree must be consistent before and after command execution, even if command failed  A flawed command implementation can lead to inconsistency

  16. Prevayler – Performance • Comparison to RDBMS problematic • RDBMS mostly run out-of-process • Usage of ODBC/JDBC/etc necessary • Published performance results taken on single-CPU machine • Synchonisation as bottleneck • Serial execution of Queries and Transactions • Can degrade performance on parallel systems • Can degrade performance on SMP sytemes  Commands still processed serially • Long running transaction may stall system • Waiting for lock on data structure

  17. Prevayler – Performance • Reading • No disk access neccessary • All required data already in memory  Quick access if data structure is organized well (using Hashtables etc)  Minimal overhead Can be siginificantly faster than RDBMS • Modifications • Disk access neccessary • WriteAhead-Logging • If StrictTransactionCensor is used: • Additional overhead • Rollbacks expensive • About same order of maginitude as RDBMS

  18. Conclusion • Prevayler can substitute RDBMS... • for moderate data volumes • if only local (in-process) access to data is required • If data accesses are mostly read-only • Benefits • No O/R-Mapping neccessary • Rapid development • High transparency for business objecs  but low transparency in data access (Query/Transaction-Modellis propriatary) • Performace • High performance for readonly access • Not designed for SMP systems • Data safety • Requires great care of developer • Prevayler does not reach reliability and robustness of modern RDBMS

  19. References • [RJW] Birrell , Andrew; Jones, Michael; Wobber, Edward: A Simple and Efficient Implementation for Small Databases, digital Systems Reseach Center, 1987 • [Carver] Carver, Frank: Thoughts about Prevayler and Databases http://radio.javaranch.com/frank/2004/12/27/1104152030000.html (11/10/2005) • [Evans] Evans, Huw: Why Object Serialization is Inappropriate for Providing Persistence in Java, Department of Computing Science, University of Glasgow • [Fowler] Fowler, Martin: Design Blikihttp://www.martinfowler.com/bliki/design.html (12 /19/2005) • [Melton] Melton, Hayden: An Evaluation of Object Prevalence, Dept. of Electrical and Electronic Engineering, University of Auckland • [ON] Obermayer, Nathanael: ACID gratis, iX Ausgabe 02/2004 • [Prevayler] Prevayler Homepage, http://www.prevayler.org • [Spille] Spille, Mike: Prevayler Revisitedhttp://www.pyrasun.com/mike/mt/archives/2004/12/25/15.02.00/index.html (11/10/2005) • [PT] Printezis, Tony: Garbage Collection in the Java HotSpot Virtual Machine, DevXhttp://www.devx.com/Java/Article/21977/0/ (01/10/2006) • [WE] Wolff, Eberhard: Die schnellste Datenbank der Welt, Java Magazin Ausgabe 06/2004

More Related