Tower (Rust)
Rust library for building reusable, composable async middleware for network services. Tower defines the Service trait (a single async fn call) and builds a composable middleware stack around it — rate limiting, retries, timeouts, load balancing, circuit breaking. Axum, tonic (gRPC), and hyper all build on Tower's Service abstraction, making Tower middleware automatically reusable across these frameworks.
Score Breakdown
⚙ Agent Friendliness
🔒 Security
Rust memory safety. Tower itself doesn't handle secrets or auth. Security depends on the middleware implemented on top of Tower's service abstraction.
⚡ Reliability
Best When
You're building or extending Axum/tonic/hyper-based Rust services and need composable middleware (retries, rate limiting, timeouts) that works across the entire Tower ecosystem.
Avoid When
You just need a simple HTTP client with retry logic — reqwest-retry is simpler. Tower shines for building reusable middleware, not consuming it.
Use Cases
- • Add retry logic to agent HTTP/gRPC calls using Tower's retry middleware without modifying the underlying service code
- • Implement rate limiting for outbound agent API calls with Tower's RateLimit layer — token bucket or concurrency-based limiting
- • Add timeout handling to agent service calls with Tower::timeout — automatically cancel requests that exceed a time limit
- • Build circuit breakers for agent external service dependencies using Tower's balance and timeout layers to prevent cascade failures
- • Compose middleware stacks (auth → rate-limit → timeout → retry) for agent service clients using ServiceBuilder
Not For
- • Simple HTTP clients — reqwest handles retries and timeouts more ergonomically for most use cases
- • Application-level business logic — Tower is infrastructure middleware, not application code
- • Teams not already using Axum/tonic/hyper — Tower's abstraction has a steep learning curve without a concrete framework to build on
Interface
Authentication
Library — no external auth. Auth can be implemented as a Tower middleware layer.
Pricing
MIT-licensed open source Rust crate from the Tokio project team.
Agent Metadata
Known Gotchas
- ⚠ Tower's Service trait error type is Box<dyn Error + Send + Sync> by default — middleware type composition creates complex type signatures that require tower::util::BoxService to erase for storage
- ⚠ poll_ready() must be called before call() — forgetting poll_ready causes panics in many middleware implementations; always use ServiceExt::ready() before calling
- ⚠ ServiceBuilder layers apply in reverse order — ServiceBuilder::new().layer(A).layer(B).service(S) applies B then A to requests, which is counter-intuitive
- ⚠ Tower middleware clones the inner service per request — services stored in Tower stacks must implement Clone; non-Clone services need Arc<Mutex<>> wrapping
- ⚠ The tower-http crate provides HTTP-specific middleware (CORS, compression, tracing) built on Tower — don't build these from scratch; check tower-http first
- ⚠ Implementing custom Tower middleware requires implementing both Service and Layer traits — the boilerplate is substantial; consider tower::service_fn() for simple one-off services
Alternatives
Full Evaluation Report
Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for Tower (Rust).
Scores are editorial opinions as of 2026-03-06.