MongoDB logo

MongoDB Software Engineer System Design Questions

16 practice questions for MongoDB Software Engineer interviews

MongoDB software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.

Software Engineer Backend Engineer Frontend Engineer Full Stack Engineer Mobile Engineer Data Engineer Data Scientist ML Engineer DevOps Engineer DevOps Engineer Product Manager SRE Security Engineer Engineering Manager Data Analyst UX/UI Designer QA Engineer

No verified questions yet for MongoDB.

system design Senior api design #1

1. [OA] Rate Limiter — Implement a rate limiter for MongoDB API requests.

Handling a high throughput of requests gracefully is critical for both performance and fairness. Implementing a rate limiter can regulate the access to MongoDB APIs efficiently.
Problem Statement: Create a class RateLimiter that allows requests to be allowed to pass if they fall within a defined rate limit.
  • Method Signature: class RateLimiter:

- def allow_request(self, user_id: str) -> bool: - Returns True if the request is allowed.
- def get_request_count(self, user_id: str) -> int: - Returns the count of requests made by the user.
Example 1:
Input: rate_limiter = RateLimiter(3, 10)
rate_limiter.allow_request("user1")
Output: True
Explanation: User can make 3 requests in 10 seconds.
Example 2:
Input: rate_limiter.allow_request("user1")
Output: False
Explanation: Only 3 requests are allowed in the 10 seconds.
Constraints:
  • 1 <= requests_per_window <= 10^3

  • 1 <= window_size <= 10^3

  • 1 <= len(user_id) <= 100.
system design Senior concurrency #2

2. [OA] Design a Job Queue System for MongoDB to Handle Concurrent Tasks.

As MongoDB scales, efficient task management is critical for maintaining performance. A job queue can ensure tasks are processed systematically and concurrently.
Problem Statement: Create a class JobQueue that allows adding jobs and processing them in concurrent threads.
  • Method Signature: class JobQueue:

- def add_job(self, job: Callable) -> None: - Adds a job to the queue.
- def process_jobs(self, num_threads: int) -> None: - Starts processing jobs using specified threads.
- def get_status(self) -> List[str]: - Returns a list of job statuses ('pending', 'completed').
Example 1:
Input: job_queue = JobQueue()
job_queue.add_job(lambda: sleep(1))
job_queue.process_jobs(2)
Output: job_queue.get_status()
Explanation: The job will be added and processed by 2 threads.
Example 2:
Input: job_queue.add_job(lambda: sleep(2))
Output: job_queue.get_status()
Output: ['pending', 'pending']
Constraints:
  • 1 <= num_threads <= 10

  • Each job will execute within reasonable limits.
system design Senior caching #3

3. [OA] LRU Cache — Implement the LRU caching mechanism used in MongoDB's query optimizer

Caching is critical for optimizing query performance in MongoDB. Implementing an LRU (Least Recently Used) cache for quick data retrieval can enhance the efficiency of repeated queries.
Define a class LRUCache that supports get and put operations.
  • Class Signature: class LRUCache:

  • def __init__(self, capacity: int): Initializes the cache with a specific capacity.

  • def get(self, key: int) -> int: Returns the value of the key if present, otherwise return -1.

  • def put(self, key: int, value: int) -> None: Updates or inserts the value if the key is not already present. When the cache reaches its capacity, it should invalidate the least recently used item before inserting a new item.


Constraints:
  • 1 <= capacity <= 30000

  • 0 <= key, value <= 10^4.
system design Senior api design #4

4. [OA] API Design — Create a simplified version of MongoDB's CRUD operations

MongoDB is centered around efficient data storage and retrieval. Designing an API for basic Create, Read, Update, and Delete operations is essential for service interactions.
Define a class MongoDBApi that simulates these operations on a collection.
  • Class Signature: class MongoDBApi:

  • def create(self, data: Dict[str, Any]) -> str:: Creates a new record and returns its ID.

  • def read(self, record_id: str) -> Dict[str, Any]: Returns the record specified by record_id.

  • def update(self, record_id: str, data: Dict[str, Any]) -> bool: Updates the record and returns success status.

  • def delete(self, record_id: str) -> bool: Deletes the record and returns success status.


Constraints:
  • Records are stored in a dictionary with unique IDs.

  • record_id is a string with a length of up to 36 characters.

Related MongoDB Software Engineer interview prep

Start practicing MongoDB questions

Sign up for free to access walkthroughs, AI-generated questions, and more.

Get Started Free