PracHub
QuestionsCoachesLearningGuidesInterview Prep
|Home/System Design/Akuna Capital

Fix and harden an object pool

Last updated: Mar 29, 2026

Quick Overview

This interview question evaluates requirements, scale assumptions, API/data design, architecture, trade-offs, failure modes, and rollout in a realistic interview setting. A strong answer for Fix and harden an object pool states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.

  • hard
  • Akuna Capital
  • System Design
  • Software Engineer

Fix and harden an object pool

Company: Akuna Capital

Role: Software Engineer

Category: System Design

Difficulty: hard

Interview Round: Take-home Project

Fix a buggy C++ object pool implementation. The current code exhibits races, double-free risks, and resource leaks under concurrent borrow/return. Refactor it into a correct, thread-safe object pool template. Requirements: - Provide borrow() that blocks (with an optional timeout) when the pool is empty, creating up to a max capacity; ensure fairness and avoid spurious wakeups. - Provide returnObject(obj) that safely returns an object; reject invalid or duplicate returns; optionally reset objects before reuse. - Enforce RAII with a scoped handle that automatically returns the object on destruction; handle must be movable but not copyable. - Ensure safe shutdown: destructor stops producers/consumers, wakes waiters, and releases resources without deadlocks. - Avoid busy-waiting; use std::mutex, std::condition_variable, and std::atomic correctly; prevent ABA issues (e.g., with generation counters). - Include minimal unit tests demonstrating correctness under multiple threads. Assume C++17 or later and document the complexity of core operations.

Quick Answer: This interview question evaluates requirements, scale assumptions, API/data design, architecture, trade-offs, failure modes, and rollout in a realistic interview setting. A strong answer for Fix and harden an object pool states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.

Related Interview Questions

  • Implement a two-user communications handler - Akuna Capital (medium)
  • Design communication handler and exceptions - Akuna Capital (medium)
  • Design an order-matching engine - Akuna Capital (hard)
  • Design user communication functions - Akuna Capital (easy)
  • Design user communication manager APIs - Akuna Capital (medium)
|Home/System Design/Akuna Capital

Fix and harden an object pool

Akuna Capital logo
Akuna Capital
Aug 10, 2025, 12:00 AM
hardSoftware EngineerTake-home ProjectSystem Design
6
0

Fix and harden an object pool

Refactor a Buggy C++ Object Pool Into a Correct, Thread-Safe Template

Context

You are given a buggy C++ object pool that suffers from races, double-free risks, ABA problems, and resource leaks during concurrent borrow/return operations. Refactor it into a robust template that is correct under concurrency and safe to shut down.

Assume C++17 or later.

Requirements

  • Implement a generic, thread-safe object pool template for objects of type T.
  • Provide borrow() that blocks when the pool is empty and creates up to a maximum capacity.
    • Also provide an overload with a timeout (e.g., borrow_for(duration)).
    • Ensure fairness among waiters (FIFO) and avoid spurious wakeups.
  • Provide returnObject(obj) to safely return an object:
    • Reject invalid returns (wrong pool) and duplicate returns.
    • Optionally reset objects before reuse (configurable functor).
  • Enforce RAII via a scoped handle that returns the object automatically when destroyed.
    • Handle must be movable but not copyable.
  • Ensure safe shutdown:
    • Destructor stops producers/consumers, wakes waiters, and releases resources without deadlocks.
  • Avoid busy-waiting; use std::mutex, std::condition_variable, and std::atomic correctly.
  • Prevent ABA issues (e.g., generation counters per item).
  • Include minimal unit tests demonstrating correctness under multiple threads.
  • Document the time complexity of core operations.

Deliverables: A single self-contained C++17 implementation plus minimal unit tests and brief complexity notes.

Constraints & Assumptions

  • Preserve the scope, facts, inputs, and requested outputs from the prompt above.
  • If the prompt leaves a detail unspecified, state a reasonable assumption before relying on it.
  • Keep the answer interview-ready: concise enough to present, but concrete enough to implement or evaluate.

Clarifying Questions to Ask

  • Clarify users, core use cases, read/write patterns, scale, latency, availability, and data retention.
  • State explicit assumptions before making sizing or architecture decisions.
  • Prioritize the functional path first, then address reliability, security, observability, and rollout.

What a Strong Answer Covers

  • A scoped requirements summary with concrete non-goals and success metrics.
  • API, data model, architecture, consistency, capacity, and operations.
  • Reasoned trade-offs among simple and scalable designs, including bottlenecks and failure modes.
  • A validation, monitoring, migration, and launch plan appropriate for the risk level.

Follow-up Questions

  • What breaks first at 10x traffic or data volume?
  • How would you degrade gracefully during dependency failures?
  • What metrics and alerts would prove the design is healthy after launch?

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More System Design•More Akuna Capital•More Software Engineer•Akuna Capital Software Engineer•Akuna Capital System Design•Software Engineer System Design

Your design canvas — auto-saved

PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.