hard

Design an Object Pool

Design a generic object pool for reusable resources (e.g., database connections). Include checkout and return operations, pool size limits, idle timeout eviction, and blocking behavior when the pool is exhausted.

Suggested time: 45 minutes

Loading the workspace...

About this problem

An object pool manages a set of reusable, expensive-to-create objects (database connections, thread resources, network sockets). Instead of creating and destroying these objects for each use, the pool maintains a collection of pre-initialized instances that clients borrow and return.

What your design needs to cover

  • Checkout and Return Pooled Objects

  • Enforce Maximum Pool Size with Blocking

  • Validate Objects on Borrow and Return

  • Configurable Idle Object Eviction

Key challenges the editorial covers

Learn from other designs

Related problems

Guides