db.serverStatus() — MongoDB Technical Interview Questions & Answers
Server-wide status and performance metrics.
db.serverStatus()
- Simple meaning: db.serverStatus() is a big server health document (connections, memory, opcounters).
- How to use: db.serverStatus().connections to peek at current connections. Admins use this; students rarely need the full dump.
- Common mistake: pasting the whole output in an interview. Pick one field.
- Interview tip: “Diagnostics for the process, not a collection query.”
Technical Interview Tip: One field from serverStatus, not the whole JSON.
Code Examples for db.serverStatus()
db.serverStatus() — working example
db.serverStatus()db.serverStatus() — serverStatus returns server-wide metrics (connections, opcounters, memory).
How to Explain db.serverStatus() to an Interviewer
What is serverStatus?
A command that returns mongod process metrics