Confused transaction logs in zookeeper

I am studying zookeeper, so I read the article "Simple, fully ordered broadcast protocol." And I really don't understand the following sentence:

"ZooKeeper uses the database in memory and saves transaction logs and periodic snapshots to disk. Zabs transaction log doubles as a transaction log with a database record, so that the transaction will only be written to disk once."

Can anyone explain this to me?

+6
source share
1 answer

Zookeeper must write transactions to disk, otherwise, if you restart zookeeper, he will forget about any transactions that he heard. The way to write zookeeper to disk is that before zookeeper responds to the transaction, it will add the transaction to the 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 inefficient on its own, since when you start zookeeper you will have to replay every transaction that it has ever processed. So periodically, zookeeper will write a snapshot of its current state in the memory database to a file. Then, at startup, zookeeper only downloads the snapshot, and all transaction logs since the snapshot was taken.

+8
source

All Articles