bb8

A full-featured async connection pool for Rust, built on Tokio.

Library
Cargo
v0.9.1
951stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
70/100Good
Development Activity72
Maintenance52
Community68
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
79/100Good
Architecture85
Code Quality85
Innovation72
Learning Curve72

bb8 is a generic, asynchronous connection pool for Rust, designed for Tokio-based applications and modeled after the synchronous r2d2 pool. Instead of opening a fresh database connection for every request — which is both slow and prone to resource exhaustion under load — bb8 maintains a managed set of live connections and hands them out for reuse, returning them to the pool when dropped.

bb8 is agnostic to the connection type it manages: backends implement the ManageConnection trait to supply the logic for creating and health-checking connections. Adapter crates such as bb8-postgres and bb8-redis provide ready-made integrations, and the pool handles sizing, idle timeouts, connection lifetimes, and health validation so applications get reliable, efficient access to their backends.

What You Get

  • An async, Tokio-based connection pool with configurable sizing and lifetimes
  • A generic ManageConnection trait so any connection type can be pooled
  • Automatic health checking and recycling of broken or expired connections
  • Ready-made backend adapters (bb8-postgres, bb8-redis) in the same workspace
  • RAII-style checkout where connections return to the pool on drop

Common Use Cases

  • Pooling async PostgreSQL connections in a high-traffic Tokio web service
  • Reusing Redis connections across many concurrent async tasks
  • Building a custom pool for any backend by implementing ManageConnection
  • Bounding concurrent database connections to avoid resource exhaustion

Under The Hood

Architecture - The core bb8 crate is small and layered: lib.rs re-exports the public surface, api.rs defines the Pool, PooledConnection, Builder, and the ManageConnection trait, while inner.rs and internals.rs hold the shared pool state — a set of idle connections behind synchronization, plus reaper logic for idle-timeout and max-lifetime enforcement. Checkout awaits an available connection (or creation of a new one up to the max), optionally validates it via the manager, and a PooledConnection guard returns it on drop. The workspace also contains postgres/ (bb8-postgres) and redis/ (bb8-redis) adapters implementing ManageConnection.

Tech Stack - Pure Rust built on the Tokio async runtime, using async/await and futures. It is a Cargo workspace with resolver 2, includes deny.toml for supply-chain/license auditing via cargo-deny, and runs CI with codecov coverage.

Code Quality - Mature and well-tested with CI, code coverage, and a clear separation between the public API and internal pool mechanics. As a long-lived crate originally derived from r2d2, its concurrency-sensitive internals are carefully scoped, and the small surface area keeps the implementation auditable.

API Design - Ergonomic and idiomatic: build a pool with Pool::builder().max_size(n).build(manager).await, then pool.get().await? yields a guard that derefs to the underlying connection. Modeling on r2d2 makes it instantly familiar to Rust developers, and the ManageConnection trait cleanly separates pool mechanics from backend specifics, so writing a new adapter is minimal boilerplate.

Used by 5 apps in this directory

TypeScript
61%
EPL-2.0

Huly Platform

Project Management · Team Chat · Collaboration

27,586

Open-source all-in-one workspace that replaces Linear, Jira, Slack, and Notion for product and engineering teams.

View details
89
Repo Health
86
Technical
62
Dependency
Built with
TypeScript61%
Svelte34%
Updated 1 weeks ago
TypeScript
61%
EPL-2.0

Huly Platform

Project Management · Team Chat · Collaboration

27,586

Open-source all-in-one workspace that replaces Linear, Jira, Slack, and Notion for product and engineering teams.

View details
89
Repo Health
86
Technical
62
Dependency
Built with
TypeScript61%
Svelte34%
Updated 1 weeks ago
Rust
49%
MIT

Svix

Developer Tools · Automation

3,390

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.

View details
90
Repo Health
77
Technical
67
Dependency
Built with
Rust49%
C#15%
Updated 3 days ago
Rust
49%
MIT

Svix

Developer Tools · Automation

3,390

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.

View details
90
Repo Health
77
Technical
67
Dependency
Built with
Rust49%
C#15%
Updated 3 days ago
Rust
71%
MIT

Trieve

AI Development · Search · Developer Tools

2,717

All-in-one self-hostable platform for hybrid search, RAG, recommendations, and analytics built on Rust and Qdrant.

View details
43
Repo Health
74
Technical
64
Dependency
Built with
Rust71%
Updated 7 months ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search