Home›Learn›MongoDB 5: running it as a DBRE
MongoDB · Chapter 5

Running MongoDB as a DBRE

What do I watch, which settings matter, and where do I look first?

The signals I watch, the logs I read, the parameters that decide most outcomes, and the commands that show the truth on a live deployment.

Chapter 5 · Running it

What I watch on every MongoDB deployment

The signals I put on a dashboard and alert on, and why each one matters.

Latency and errorswhat users feelp99 within target
Connectionsin use vs availablealert at 80%
WiredTiger cachefill and dirty sharealert near 95% full
Replicationlag and member statesone PRIMARY, others SECONDARY
Oplog windowhours a secondary can be downlonger than maintenance
Electionsunplanned primary changesnone unexpected
Disk and backupsfree space, last restore testrestore never tested

Example dashboard: the thresholds are starting points I would tune per system, and the colors are made up for the picture.

SignalWhy I watch itWhere it comes from
Latency and errorsWhat users feel.Slow query log, $currentOp, the driver
ConnectionsEach costs memory; at the limit, new ones are refused.serverStatus().connections
WiredTiger cacheNear 95% full or 20% dirty, app threads help evict and latency jumps.serverStatus().wiredTiger.cache
Replication and electionsA failover loses w: 1 writes that had not replicated.rs.status(), rs.printSecondaryReplicationInfo()
Oplog windowShorter than a maintenance window means a full resync.db.getReplicationInfo()
Disk and backupsA backup counts only once a restore has been tested.The OS, your backup tool

Run the checks on your own deployment with the health check.

Every log file a DBA needs to know

Same idea as PostgreSQL: exact names, one job per log, one check per incident. The rule is written once on the PostgreSQL page. This table adds the operational logs a DBA reads first: server, error, slow.

LogExact file nameWhere it sits (on-prem)What it doesWhat to check in it
MongoDB
Journal
journal/WiredTigerLog.0000000123journal/ inside the dbPathWiredTiger's write-ahead log. It covers the gap between checkpoints (about 60 s). j:true waits for this.Check that the files exist and turn over. Check journal commit latency in db.serverStatus().wiredTiger.log.
MongoDB
Oplog
local.oplog.rsA capped collection in the local database. Not a fileOrdered record of every write on the primary. Secondaries tail it. Its size divided by write rate is the catch-up window.rs.printReplicationInfo(). "log length start to end" is the window in hours. Compare it to your longest maintenance.
MongoDB
mongod log
mongod.log/var/log/mongodb/mongod.logThe server's diary. Elections. Slow operations (over the profiler threshold). Connection events.Election events and slow-operation lines around the incident start. Stepdown and stepup pairs mark every failover.

The parameters DBAs actually touch during outages

Same three outage rules as PostgreSQL: Safe live lever, Planned change, Do not touch. What each one means is written once on the PostgreSQL page.

MongoDB · WiredTiger Outage parameters

ParameterWhat it doesDuring an outage
storage.wiredTiger.engineConfig.cacheSizeGBSize of the WiredTiger cache. Default is about 50% of (RAM minus 1 GB), or 256 MB if that is larger.Planned change. It is set in the config file. Applying it means a rolling restart of the set. Mid-incident, the evidence comes first: serverStatus().wiredTiger.cache. The live fixes are killing the cache-churning operation or the pinned snapshot, not the cache size.
oplogSizeMB / replSetResizeOplogSize of the capped oplog collection. Window equals size divided by write rate.Safe live lever (dynamic since 3.6; minRetentionHours since 4.4). Enlarge the oplog on every member, one at a time, before planned maintenance so the window exceeds the downtime. replSetResizeOplog changes only the member it runs on. It cannot recover entries that already rolled off.
writeConcern / readConcernPer-operation guarantees set by the application. How many members must acknowledge a write (w). Whether it must be journaled (j). Which writes a read may see.Application change, not a server knob. Do not weaken w:'majority' mid-outage to make writes "fast again", unless rollback-on-election is explicitly acceptable. Shifting readPreference to secondaries sheds primary load but serves staler data. That is a routing decision, not a repair.
// check db.serverStatus().wiredTiger.cache // dirty bytes + app-thread evictions rs.printReplicationInfo() // the oplog window, in hours // the safe lever: extend the window before maintenance (4.4+) db.adminCommand({replSetResizeOplog: 1, size: 20480}) // MB
See it yourself · copy-paste commands

Open a real database and check every claim on this page

Same rule as PostgreSQL: every mechanism above is observable on a running server in under two minutes. The full version is on the PostgreSQL page.

Run it locally: docker-compose-mongo.yml starts MongoDB 8.0 on port 27017 with a shop database. docker compose -f docker-compose-mongo.yml up -d, then run the commands below against it.

MongoDB · mongosh + shell
// where is everything?
db.adminCommand({getCmdLineOpts: 1})
// → parsed.storage.dbPath
db.users.stats().wiredTiger.uri
// → "table:collection-2-4471…"
$ ls /var/lib/mongo/journal
// → WiredTigerLog.0000000123

// the oplog: size, window, latest entry
rs.printReplicationInfo()
rs.status()  // members + optime lag

// cache pressure
db.serverStatus().wiredTiger.cache
Next · chapter 6When it breaksPlaybooks, from the symptom to the fix← Chapter 4: High availability
Part 1 of 4 · Learn · 56 pagesAll pages

How do databases actually work? From one row on disk to transactions: the words you need, PostgreSQL, MySQL and MongoDB from the files up, then Redis, Cassandra and vector search, side by side, and the query and concurrency traps.

Start 1: the basicsStart 2: ten conceptsStart 3: how a query travelsStart 4: napkin mathThe courseShort videosPostgreSQL 1: why PostgreSQLPostgreSQL 2: how it stores your dataPostgreSQL 3: what happens on every writePostgreSQL 4: high availability with PatroniPostgreSQL 5: running it as a DBREPostgreSQL 6: when it breaksPostgreSQL on Kubernetes: CloudNativePGMySQL 1: why MySQLMySQL 2: how it stores your dataMySQL 3: what happens on every writeMySQL 4: high availability with InnoDB ClusterMySQL 5: running it as a DBREMySQL 6: when it breaksMySQL failover with OrchestratorMySQL on Kubernetes: the Percona operatorsMongoDB 1: why MongoDBMongoDB 2: how it stores your dataMongoDB 3: what happens on every writeMongoDB 4: high availability with replica setsMongoDB 5: running it as a DBREMongoDB 6: when it breaksMongoDB on Kubernetes: the Percona operatorB-tree and LSM treeRedis 1: why RedisRedis 2: how it stores your dataRedis 3: high availabilityRedis 4: running it as a DBRERedis 5: when it breaksCassandra 1: why CassandraCassandra 2: how it stores your dataCassandra 3: high availabilityCassandra 4: running it as a DBRECassandra 5: when it breaksVector databases 1: why vector searchVector databases 2: how it stores your dataVector databases 3: high availabilityVector databases 4: running it as a DBREVector databases 5: when it breaksDatabase familiesEngines side by sideQueries that look fine and are notLost updates and write skewMany servers 1: keep a copy runningMany servers 2: who is the leaderMany servers 3: CAP as settingsMany servers 4: unique IDsMany servers 5: split the dataMany servers 6: across servicesMany servers 7: a thousand databasesStaff path, zero to architect