deadpool
Dead simple async connection and object pool for Rust
Repository Health
Technical Analysis
Deadpool is a generic async object and connection pool for Rust, offering both a managed pool (deadpool::managed::Pool) that creates and recycles objects on demand, and an unmanaged pool (deadpool::unmanaged::Pool) for pooling pre-created objects. It’s runtime-agnostic by default and adds optional Tokio, async-std, or smol support only when timeout functionality is needed.
The deadpool-rs org builds on this core crate with ready-made backends for popular services — deadpool-postgres, deadpool-redis, deadpool-sqlite, deadpool-diesel, deadpool-lapin, and others — each implementing the Manager trait to recycle connections for that specific client library. This makes deadpool the shared foundation most Rust database/service connection pools in the ecosystem are built on top of.
What You Get
- A managed
Pool<M: Manager>that creates and recycles objects via a user-implementedManagertrait - An unmanaged
Poolfor holding pre-created objects with no creation/recycling logic - Pluggable async runtime support (Tokio, async-std, smol) enabled only via opt-in
rt_*features - Pre/post hooks for custom checkout/recycle behavior, plus timeout and queue-mode configuration
- Serde support for deserializing pool configuration from config files or environment variables
Common Use Cases
- Pooling database connections for Postgres, SQLite, or MySQL via the
deadpool-postgres/deadpool-sqlite/deadpool-dieselbackend crates - Pooling Redis connections via
deadpool-redisfor caching and pub/sub workloads - Pooling AMQP/RabbitMQ channels via
deadpool-lapinfor message-queue producers/consumers - Building a custom pool for any expensive-to-create resource (HTTP clients, gRPC channels) by implementing the
Managertrait directly
Under The Hood
Architecture - The core crate (crates/deadpool/src/) splits into managed/ and unmanaged/ modules behind separate feature flags. The managed pool (managed/pool.rs) wraps an Arc<PoolInner<M>> guarded by a tokio::sync::Semaphore for checkout concurrency control, with Object<M> (managed/object.rs) wrapping the pooled value plus metadata and a DropGuard (managed/dropguard.rs) that returns objects to the pool automatically on drop. Manager (managed/manager.rs) is the trait downstream crates (deadpool-postgres, deadpool-redis, etc.) implement to define how their specific connection type is created and recycled, making deadpool a policy layer over a caller-supplied resource lifecycle.
Tech Stack - Pure Rust (93% of the repo by bytes), edition 2024, minimum Rust 1.85, with #![forbid(unsafe_code)] declared in the README badge. Depends non-optionally on tokio::sync::Semaphore for the checkout primitive, but keeps full Tokio runtime features, async-std, and smol behind separate opt-in rt_* feature flags so non-Tokio users aren’t forced to pull in the full runtime. The repo is a Cargo workspace (crates/) housing the core crate alongside ten sibling backend crates.
Code Quality - The deadpool crate has 11 files under tests/ covering managed/unmanaged pool behavior, plus Criterion benchmarks (benches/managed.rs, benches/unmanaged.rs) for performance regression tracking. CI is defined via a shared Jsonnet template (ci.jsonnet) generating per-crate GitHub Actions workflows, and a check-reexports.sh script guards against accidental API drift across the workspace’s many crates.
API Design - The Manager trait’s two required methods (create, recycle) are the only things a new backend needs to implement to gain a fully-featured async pool, which is why the ecosystem has ten-plus deadpool-* backend crates built on this core. The managed/unmanaged split, opt-in runtime features, and hook system (pre/post-checkout) add real configurability but also mean new users must pick the right feature combination up front — the README’s feature table exists precisely to guide that choice.
Used by 4 apps in this directory
Laminar
AI Development · Monitoring
Open-source observability platform purpose-built for AI agents — trace, evaluate, debug, and monitor at scale with SQL access and real-time replay.
Lemmy
Community · Social Media
Federated, self-hosted Reddit alternative with full community ownership and no corporate control.
Stalwart
Collaboration
All-in-one secure mail and collaboration server covering IMAP, JMAP, SMTP, CalDAV, CardDAV, and WebDAV in a single memory-safe Rust binary.
Svix
Developer Tools · Automation
Open source, self-hostable webhook infrastructure that handles delivery, retries, HMAC signing, and multi-tenant event management so you never have to build a webhooks system from scratch.