How does mongod write data to hard drive? It performs write operation
per every document? Per every chunk? And similarly: how about reads?
Also: are those reads and writes random or sequential?
As MongoDB BOL Here Journaling Process Changed in version 3.2
.
With journaling
, WiredTiger
creates one journal record for each client initiated write
operation. The journal record includes any internal write operations
caused by the initial write. For example, an update to a document in a collection may result in modifications to the indexes; WiredTiger
creates a single journal record
that includes both the update operation and its associated index modifications.
MongoDB configures WiredTiger to use in-memory buffering for storing the journal records. Threads coordinate to allocate and copy into their portion of the buffer. All journal records up to 128 kB are buffered
.
For the journal files, MongoDB creates a subdirectory named journal under the dbPath
directory. WiredTiger journal files have names with the following format WiredTigerLog.<sequence>
where <sequence>
is a zero-padded
number starting from 0000000001
.
Journal files contain a record per each write operation
. Each record has a unique identifier. MongoDB
configures WiredTiger
to use snappy compression for the journaling data.
Note :
To provide durability in the event of a failure, MongoDB uses write ahead logging to on-disk journal
files.
As MongoDB documented Here A sequential
, binary transaction log
used to bring the database into a valid state in the event of a hard shutdown. Journaling writes data first to the journal and then to the core data files. MongoDB enables journaling by default for 64-bit
builds of MongoDB version 2.0
and newer. Journal files are pre-allocated and exist as files in the data directory.
Going further: are writes made during writing journal file similar to
those when creating snapshot?
If you place the journal
on a different filesystem
from your data files, you cannot use a filesystem
snapshot alone to capture valid backups of a dbPath directory. In this case, use fsyncLock()
to ensure that database files are consistent before the snapshot and fsyncUnlock()
once the snapshot is complete.
Note :
db.fsyncUnlock() is an administrative operation.
For Further your ref Here Here