21 releases

0.4.13 Jun 17, 2022
0.4.12 Feb 16, 2022
0.4.11 Nov 18, 2021
0.4.8 May 28, 2021
0.0.1 Dec 23, 2016

#3 in Network programming

Download history 831059/week @ 2024-03-01 803293/week @ 2024-03-08 843764/week @ 2024-03-15 869391/week @ 2024-03-22 852461/week @ 2024-03-29 895892/week @ 2024-04-05 934080/week @ 2024-04-12 960444/week @ 2024-04-19 939986/week @ 2024-04-26 943758/week @ 2024-05-03 1010986/week @ 2024-05-10 1028479/week @ 2024-05-17 1005071/week @ 2024-05-24 1151729/week @ 2024-05-31 1113738/week @ 2024-06-07 916532/week @ 2024-06-14

4,378,730 downloads per month
Used in 4,594 crates (722 directly)

MIT license

7.5K SLoC


Tower is a library of modular and reusable components for building robust networking clients and servers.

Crates.io Documentation Documentation (master) MIT licensed Build Status Discord chat


Tower aims to make it as easy as possible to build robust networking clients and servers. It is protocol agnostic, but is designed around a request / response pattern. If your protocol is entirely stream based, Tower may not be a good fit.

Tower provides a simple core abstraction, the Service trait, which represents an asynchronous function taking a request and returning either a response or an error. This abstraction can be used to model both clients and servers.

Generic components, like timeouts, rate limiting, and load balancing, can be modeled as Services that wrap some inner service and apply additional behavior before or after the inner service is called. This allows implementing these components in a protocol-agnostic, composable way. Typically, such services are referred to as middleware.

An additional abstraction, the Layer trait, is used to compose middleware with Services. If a Service can be thought of as an asynchronous function from a request type to a response type, a Layer is a function taking a Service of one type and returning a Service of a different type. The ServiceBuilder type is used to add middleware to a service by composing it with multiple multiple Layers.

The Tower Ecosystem

Tower is made up of the following crates:

Since the Service and Layer traits are important integration points for all libraries using Tower, they are kept as stable as possible, and breaking changes are made rarely. Therefore, they are defined in separate crates, tower-service and tower-layer. This crate contains re-exports of those core traits, implementations of commonly-used middleware, and utilities for working with Services and Layers. Finally, the tower-test crate provides tools for testing programs using Tower.


Tower provides an abstraction layer, and generic implementations of various middleware. This means that the tower crate on its own does not provide a working implementation of a network client or server. Instead, Tower's Service trait provides an integration point between application code, libraries providing middleware implementations, and libraries that implement servers and/or clients for various network protocols.

Depending on your particular use case, you might use Tower in several ways:

  • Implementing application logic for a networked program. You might use the Service trait to model your application's behavior, and use the middleware provided by this crate and by other libraries to add functionality to clients and servers provided by one or more protocol implementations.

  • Implementing middleware to add custom behavior to network clients and servers in a reusable manner. This might be general-purpose middleware (and if it is, please consider releasing your middleware as a library for other Tower users!) or application-specific behavior that needs to be shared between multiple clients or servers.

  • Implementing a network protocol. Libraries that implement network protocols (such as HTTP) can depend on tower-service to use the Service trait as an integration point between the protocol and user code. For example, a client for some protocol might implement Service, allowing users to add arbitrary Tower middleware to those clients. Similarly, a server might be created from a user-provided Service.

    Additionally, when a network protocol requires functionality already provided by existing Tower middleware, a protocol implementation might use Tower middleware internally, as well as as an integration point.

Library Support

A number of third-party libraries support Tower and the Service trait. The following is an incomplete list of such libraries:

If you're the maintainer of a crate that supports Tower, we'd love to add your crate to this list! Please open a PR adding a brief description of your library!

Getting Started

The various middleware implementations provided by this crate are feature flagged, so that users can only compile the parts of Tower they need. By default, all the optional middleware are disabled.

To get started using all of Tower's optional middleware, add this to your Cargo.toml:

tower = { version = "0.4", features = ["full"] }

Alternatively, you can only enable some features. For example, to enable only the retry and timeout middleware, write:

tower = { version = "0.4", features = ["retry", "timeout"] }

See here for a complete list of all middleware provided by Tower.

Supported Rust Versions

Tower will keep a rolling MSRV (minimum supported Rust version) policy of at least 6 months. When increasing the MSRV, the new Rust version must have been released at least six months ago. The current MSRV is 1.49.0.


This project is licensed under the MIT license.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Tower by you, shall be licensed as MIT, without any additional terms or conditions.


~35K SLoC