Concurrency & Locks
Every problem here is about several threads sharing one structure. MongoDB runs each of them in production, from the capped collection that holds the oplog to the pool of connections every driver keeps under maxPoolSize, which defaults to 100 connections per server. You'll build a bounded queue that pushes back on a fast producer, a ring buffer that grows into an overwriting capped collection, a pool where each waiting caller has its own deadline, and a read-write lock that has to keep a writer from starving under heavy reads.
The base version of each runs without locks, so you can test it on its own first. Then the follow-up adds the locks and condition variables MongoDB checks when it scores concurrency safety, and that's where most of the scoring happens. Practice the base and the locking layer as one motion. A read-write lock, for example, takes about five minutes to write, and explaining its fairness rule can take the rest of the round.
For settling the interface, choosing the map and its partner, and testing a design build, see Data Structure Design.
MongoDBPremium lesson · Coding round
The 4 MongoDB problems are below.
- A Premium questionCoding · Medium · Frequently asked
- A Premium questionCoding · Medium · Frequently asked
- A Premium questionCoding · Medium
+ 1 more in this lesson
Each with hints, the follow-up and a tested solution.
Get the MongoDB questions$49 a year · all 122 companies · instant access
276 MongoDB interview reports
MongoDB interview guideKnow what MongoDB asks before you walk in.
31 coding · 5 system design · 17 behavioral questions
Get their questions first.
InterviewLegend is independent and not affiliated with or endorsed by any company it covers.