QA
Intermediate LevelMongoDB & Mongoose

How do you monitor WiredTiger cache size using db.serverStatus()?

❓ Interview Prompt: Explain db.serverStatus(), monitoring wiredTiger.cache, tracked dirty bytes, and dirty page eviction rates.

Running 'db.serverStatus().wiredtiger.cache' tracks active memory usage, dirty page bytes, and cache eviction rates to prevent memory thrashing.

Code Implementation Example

typescript
import mongoose from 'mongoose';

async function checkWiredTigerCache() {
  const adminDb = mongoose.connection.db!.admin();
  const status = await adminDb.command({ serverStatus: 1 });
  console.log('Cache Usage (MB):', (status.wiredTiger.cache['bytes currently in the cache'] / 1024 / 1024).toFixed(2));
}
💡Monitoring WiredTiger memory cache statistics via serverStatus.
🎯 Interview Key Takeaway

Monitor WiredTiger cache metrics with serverStatus to ensure active working sets fit in RAM.

#WiredTiger#serverStatus#Cache Metrics#Intermediate
Back to all MongoDB & Mongoose Questions→

More MongoDB & Mongoose Interview Questions

Beginner LevelMongoDB & Mongoose

How does the MongoDB Aggregation Pipeline work? Explain $match, $group, $lookup, and $project.

Beginner LevelMongoDB & Mongoose

What is MongoDB and how does the BSON document data model work?

Beginner LevelMongoDB & Mongoose

What is the structure of a MongoDB ObjectId and how is it generated?