Question

I am studying zookeeper, so I read the paper "A simple totally ordered broadcast protocol". And I dont really understand the following sentence:

"ZooKeeper uses an in-memory database and stores transaction logs and periodic snapshots on disk. Zab’s transaction log doubles as the database write-ahead transaction log so that a transaction will only be written to the disk once."

Is there anyone can explain it to me?

Was it helpful?

Solution

Zookeeper needs to write transactions to disk, otherwise if you restart zookeeper, it would forget about any transasctions it has heard. The way zookeeper writes to disk, is that before zookeeper responds to a transaction, it will append the transaction to a transaction log file. When the transaction log file reaches a certain size, a new transaction log file is created.

Writing to transaction log files is not efficient by itself, since on startup zookeeper would have to replay every transaction it ever processed. So periodically, zookeeper will write a snapshot of the current state of its in memory database to file. Then when starting up, zookeeper only has to load the snapshot, and any transaction logs since the snapshot was created.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top