Embed
Email

Prevayler_en

Document Sample

Shared by: dandanhuanghuang
Categories
Tags
Stats
views:
4
posted:
1/22/2012
language:
pages:
19
Prevayler









Johannes Passing, 02/01/2006

Agenda



Introduction

Object Prevalence

Concepts

Prevayler

Concepts

Transaction processing

Performance

Conclusion









HPI, Seminar English for IT Systems Engineering - WS2005/2006

2

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 «interface»

IBar



implementation matches

transient implementation Bar Foo

ACID



1 *





No mapping between data models

rapid development

quick prototyping possible



HPI, Seminar English for IT Systems Engineering - WS2005/2006

3

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









HPI, Seminar English for IT Systems Engineering - WS2005/2006

4

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







HPI, Seminar English for IT Systems Engineering - WS2005/2006

5

Object Prevalence

Core Concepts (2)



Periodic snapshot 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





HPI, Seminar English for IT Systems Engineering - WS2005/2006

6

Prevayler

Project Prevayler



Founded by 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







HPI, Seminar English for IT Systems Engineering - WS2005/2006

7

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









HPI, Seminar English for IT Systems Engineering - WS2005/2006

8

Prevayler – Concepts

Data access

Command (DML)





Indirect access thru command objects RDBMS

Readonly: Query-object

Modifications: Transaction-object Pages









Only programmatic access

No Query Language

Prevayler



Commands are opaque to Prevayler Command

(Transaction)

Prevayler cannot determine

actual modifcations made Objects

Synchronisation must be performed

on Data structure level

Much more coarse-grained than

RDBMS (page level)



HPI, Seminar English for IT Systems Engineering - WS2005/2006

9

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;

}





HPI, Seminar English for IT Systems Engineering - WS2005/2006

10

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 {

public void executeOn(

Object prevalentSystem,

Date executionTime);

}





HPI, Seminar English for IT Systems Engineering - WS2005/2006

11

Prevayler – Data safety

Snapshots



Serialization of complete object tree

Standard: Java Object Serialization

All objects are serialized, not only ‚dirty‘ objects

Performed periodically





Process

1. Acquire lock on object tree

2. Serialize tree into file

3. Release lock

4. Mark snapshot file as complete

5. Truncate command log, delete old snapshot (optional)



 Process may take several minutes  Downtime

 Can be avoided by using a replica



HPI, Seminar English for IT Systems Engineering - WS2005/2006

12

Prevayler – Data safety

Transaction processing



Process

1. Serializability-Test of command object

2. Approval by Censor

3. Adding entry to Transaction Log

4. 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





HPI, Seminar English for IT Systems Engineering - WS2005/2006

13

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

HPI, Seminar English for IT Systems Engineering - WS2005/2006

14

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





HPI, Seminar English for IT Systems Engineering - WS2005/2006

15

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









HPI, Seminar English for IT Systems Engineering - WS2005/2006

16

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

HPI, Seminar English for IT Systems Engineering - WS2005/2006

17

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-Modell is

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



HPI, Seminar English for IT Systems Engineering - WS2005/2006

18

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 Bliki

http://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 Revisited

http://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, DevX

http://www.devx.com/Java/Article/21977/0/ (01/10/2006)



[WE] Wolff, Eberhard: Die schnellste Datenbank der Welt, Java Magazin Ausgabe 06/2004





HPI, Seminar English for IT Systems Engineering - WS2005/2006

19



Other docs by dandanhuanghua...
GEOL 104 – Earth Through Time Laboratory
Views: 0  |  Downloads: 0
WECC
Views: 1  |  Downloads: 0
FA
Views: 6  |  Downloads: 0
MMARS Liaisons - Mass.Gov
Views: 4  |  Downloads: 0
Papua New Guinea Update
Views: 1  |  Downloads: 0
INF739_PH
Views: 0  |  Downloads: 0
Dashboard
Views: 21  |  Downloads: 0
By registering with docstoc.com you agree to our
privacy policy

You are almost ready to download!

You are almost ready to download!