March 26, 2023

top rust frameworks

I researched the top Rust web frameworks by examining five sources: two articles, one from OurCodeWorld and another from LogRocket Blog ; a blog post from kerkour.com ; and two Reddit threads . While there was no unanimous consensus on a single best framework, some frameworks, such as Rocket, Actix-web, and Tide, were mentioned more frequently and positively than others. The sources provided different perspectives, with some focusing on performance benchmarks and others on community discussions . My level of uncertainty is moderate, as the sources were diverse and opinions varied.

Have an opinion? Send us proposed edits/additions and we may incorporate them into this article with credit.

Words

565

Time

3m 42s

Contributors

86

Words read

9.8k

Rocket

Rocket

Rocket is a popular Rust web framework known for its flexibility and type safety. It integrates with the Rust ecosystem, making it easy to use existing libraries and tools, and follows a "convention over configuration" philosophy. Rocket offers easy-to-use macros for writing requests and responses, scales well for larger applications, and provides a SQLx database driver for type-safe SQL access. It also generates OpenAPI (Swagger) specification documents automatically and supports various web development tasks, including REST API, WebSockets, and server-side rendering (SSR). Rocket has a supportive and active community. However, some developers are hesitant to use it in production due to its reliance on a single developer.
Tide

Tide

Tide is another Rust web framework with a clean and easy-to-use API. It is based on Actix-web but takes a lower-level approach. Tide provides async/await support, type-safe routing, request guards, templating, session management, and websockets support. It performs well in benchmark tests and is compatible with various HTTP clients. Tide scales well in performance and features, favors simplicity, and has comprehensive documentation. It is suitable for REST APIs, web sockets, and server-sent events (SSE). Tide uses std-async instead of Tokio, and some developers enjoy using it at work.
Actix-web

Actix-web

Actix-web is a high-speed Rust web framework based on the Actor model. It offers a robust set of features for building web applications, including asynchronous I/O, WebSockets, middleware support, and more. Actix-web has the largest ecosystem and community among the frameworks discussed, and it performed well in benchmark tests for basic request handling. However, some developers have experienced a number of "papercuts" with Actix-web and are transitioning to Axum for new projects.

Warp

Warp is a fast and flexible web server framework built on top of Tokio. It is easy to use and comes with many features out of the box. In benchmark tests, Warp was fast but struggled at higher connection concurrency levels. Warp and Axum are both based on Hyper, resulting in similar performance and features.
Axum

Axum

Axum is a Rust web framework focused on ergonomics and modularity and is maintained by the Tokio team. It has access to the Tokio ecosystem and community. Axum's performance is considered good enough for most use cases, and it has a relatively small number of open issues compared to other frameworks. Some developers prefer Axum's middleware implementation over that of Actix-web. Axum and Poem perform similarly in terms of speed, but Poem has better openapi integration. In conclusion, there is no clear winner among these Rust web frameworks, as each offers its own set of strengths and weaknesses. Developers should consider factors such as community support, performance, and specific project requirements when choosing a framework.

Jump to top

Research

"https://blog.logrocket.com/top-rust-web-frameworks/"

  • Rust is a popular language for developers because of its open source, fast, reliable, and high-performance features
  • A web framework is a software tool that supports the development of web applications
  • Web frameworks range from a small codebase for micro apps to a large codebase for enterprise apps and everything in between
  • Web frameworks provide libraries of support for databases, templating, sessions, migration, and other utilities to speed up the development process
  • More simplistic frameworks focus more acutely on frontend management for static content rendering
  • When choosing the appropriate web framework for your project, your development team should consider the relative importance of security, flexibility, community growth, project size, releases, documentation, and community support
  • Rust web frameworks can provide the web services, web resources, and web APIs that development teams need to help bring their ideas to life
  • Rust uses a tool called wasm-pack to assemble and package crates that target WebAssembly (WASM).
  • There are several Rust frontend web frameworks designed to create full-fledged JavaScript apps in Rust providing easy API binding between the languages:
    • Stdweb: a frontend standard library that communicates directly with JavaScript web APIs
    • Yew: a component-based framework similar to React and Elm with support for multi-threading
    • Percy: a toolkit developed for building single-page apps (SPAs) and managing UI
    • Sauron: a micro frontend framework inspired by The Elm Architecture with support for events, state management, and components
    • Dioxus: a UI library that’s React-like and built around a virtual DOM to support building cross-platform apps for web, mobile, and desktop
    • Iced: a GUI library for cross-platform development that supports reactive programming and inbuilt widgets
    • Tauri: a Rust library built as a light JavaScript framework for building desktop applications with the integration of any frontend technology that renders HTML, CSS, and JavaScript into your web view for its UI
  • There are several Rust backend web frameworks:
    • Rocket: a popular web framework that makes it easy for developers to write fast web apps without skimping on security, flexibility, or function
    • Actix: another powerful backend web framework with architectural pattern based on Rust’s actor system
    • Axum: a web framework that focuses on providing a foundation for building asynchronous, scalable, and maintainable web applications
    • warp: designed to be fast, lightweight, and composable, making it ideal for building high-performance web

"https://ourcodeworld.com/articles/read/1823/the-best-rust-web-frameworks-in-2023"

  • Rocket:
    • A web framework for Rust that provides flexibility and type safety.
    • Integrates tightly with the Rust ecosystem, making it easy to use existing libraries and tools.
    • Follows a “convention over configuration” philosophy and aims to get up and running with minimal configuration.
    • Offers easy-to-use macros that make writing requests and responses quick and concise.
    • Scales well for bigger and more complex web applications.
    • Provides a SQLx database driver for type-safe, async/await-friendly SQL access.
    • Offers automatic generation of OpenAPI (Swagger) specification documents that can inform client and server code.
    • Suitable for REST API, WebSockets, server-side rendering (SSR) of client-side applications, testing, and many other web development tasks.
    • Has a supportive and active community.
  • Tide:
    • A web framework for Rust that offers a clean and easy-to-use API for building web applications.
    • Based on Actix-web with a lower-level approach.
    • Provides async/await support, type-safe routing, request guards, templating support, session management, and websockets support.
    • Shows good performance in benchmark tests.
    • Compatible with a wide range of HTTP clients.
    • Scales well in both the performance and feature dimensions.
    • Favors simplicity and supports ease of learning.
    • Offers good documentation, including sample code, API reference, and a user guide.
    • Useful for REST APIs, web sockets, and server-sent events (SSE).
  • Actix-web:
    • A high-speed web framework written in Rust that is based on the Actor model.
    • Provides a robust set of features for building web applications, including asynchronous I/O, WebSockets, middleware support, and more.
    • Offers a type-safe builder-pattern based API system.
    • Handles thousands of connections concurrently with minimal overhead.
    • Provides HTTP/2 support and automated TLS support using OpenSSL.
    • Offers both Synchronous and Asynchronous APIs.
    • Has good performance and is suitable for high-traffic web applications.
  • Warp:
    • A fast, flexible web server framework built on top of Tokio.
    • Provides a simple and composable API for handling requests with good performance.
    • Offers automatic TLS, HTTP/2 support, server-sent events (SSE), WebSockets, path parameters, query parameters, JSON body parsing, multipart forms, static file serving, and more.
    • Takes inspiration

"Which Rust web framework to choose in 2022 (with code examples)"

  • This webpage contains a Reddit discussion thread on Rust web frameworks with comments posted by different Reddit users.
  • One comment mentions the absence of Rocket, despite being more popular on GitHub relative to other Rust web frameworks.
  • There was a long period of time when Rocket had no commits after August last year, but that changed a week ago, according to one of the comments.
  • A user shared a link to a public information post that talks about the hiatus of Rocket’s development.
  • Some comments mention the bus factor of 1 regarding Rocket and how that might make people hesitant to use it for production purposes.
  • There is no specific or recommended approach to creating a route handler in Actix-web. Different examples demonstrate different ways of handling routes, such as using web::get().to(greet) or defining a route as #[get("/{id}/{name}/index.html")]. - One user suggests the use of specific types like Path or Json rather than the original request, which can make data retrieval easier. - Axum is backed by Tokio and thus has access to its ecosystem and community - There are a number of papercuts in Actix-web, according to one comment, and that's why the user is committing to Axum for new projects and even porting existing ones from Actix-web. - A user mentions Axum-extra'sfrom_fnwhich they find much nicer than all theFuture/Service` implementation in Axum. This middleware allegedly is added to the main crate. - There is a comparison between Axum and Poem, which yields similar results in terms of speed. However, Poem has openapi integration superior to Axum. - There is a mention of the similarities of Axum and Poem due to both being based on Hyper. - Tide uses std-async instead of Tokio, and a user mentions enjoying its usage at work. - Warp, in terms of code, is the most no-magic framework and instills confidence in a user. - However, there are also comments suggesting complex types and compile-time magic in Warp.

"https://kerkour.com/rust-web-framework-2022"

  • The webpage provides information on the top Rust web frameworks as of February 2022.
  • There are three Rust web frameworks included in the list: actix-web, warp, and axum.
  • actix-web is described as a powerful, pragmatic, and extremely fast web framework for Rust. It has a total of 5,134,720 downloads and around 13.3k GitHub stars. The framework has around 500 packages, 57 official examples, 95 open issues, and 1234 closed issues.
  • warp is described as a framework that serves the web at warp speeds. It has a total of 4,114,095 downloads and around 6k GitHub stars. The framework has around 184 packages, 24 official examples, 134 open issues, and 421 closed issues.
  • axum is described as a web framework that focuses on ergonomics and modularity and is maintained by the Tokio team. It has a total of 235,150 downloads and around 3.6k GitHub stars. The framework has around 50 packages, 36 official examples, 6 open issues, and 192 closed issues.
  • Other Rust frameworks like poem, hyper, rocket, tide, rouille, and iron were not included in the list because they are either too young, too low-level, don’t support async-await, don’t support Tokio, or are no longer maintained.
  • The frameworks’ performance was compared based on the TechEmpower Web Framework Benchmarks. All the frameworks included in the list have good enough™ performance for most use cases.
  • The ecosystem and community of the frameworks were also compared. actix-web was noted to have the biggest ecosystem and community. However, axum is also part of the Tokio project, which has a huge ecosystem and community.
  • The page provides JSON deserialization code examples for each framework, showing that all three frameworks use generics to provide easy JSON deserialization.
  • For routing, axum was noted as the clear winner, followed closely by actix-web, while warp was described as having a functional API that favors composition.
  • Lastly, the frameworks’ middleware solutions were compared using code examples. The page provides middleware code examples using actix-web, showing how it uses the Transform trait, as well as warp and axum, where the

"Benchmarked: The state of Rust web frameworks in 2021"

  • URL: # “Benchmarked: The state of Rust web frameworks in 2021” - 2 years ago - r/rust - 129 points
  • The article provides benchmarks for comparing different Rust web frameworks.
  • The benchmarks were conducted by running each framework’s “Hello, World!” program.
  • All frameworks were tested on Windows using WSL2. The client was run on the same machine as the server to eliminate network latency.
  • The benchmarks were performed using two different allocation libraries: jemalloc and snmalloc.
  • The web frameworks tested were:
    • Actix-web
    • Gotham
    • Iron
    • Nickel.rs
    • Rocket
    • Tide
    • Warp
    • Yew
  • The article discusses the results for both raw request/second and for median request time under load.
  • The overall results showed that Actix-web, Gotham, Rocket, and Tide were fast and performed similarly well. Warp was also a fast performer, but struggled at higher connection concurrency. Nickel.rs was the slowest of all frameworks tested, by a wide margin.
  • The authors acknowledge that this benchmark is limited and only provides one type of test for very basic request handling. They encourage readers to conduct their own benchmarks for specific use-cases.
  • Some comments suggest improving the benchmarking methodology by including more information on hardware and software stack, publishing source code alongside benchmarks, and testing on multiple machines.
  • Others suggest that the benchmark methodology is flawed because the client and server were both run on the same machine, potentially skewing the results. They suggest alternatives such as running multiple clients on different machines.
  • Comments also recommend additional frameworks to test, such as Juniper and Async-graphql.
  • There is a discussion on the difficulty of Rust adoption for web development, particularly relative to other languages and existing web frameworks.
  • There is a debate over the validity of the benchmark results, with some comments suggesting that they are misleading due to the testing methodology. Others argue that the benchmarks are a useful starting point for evaluating web frameworks, but should be used in conjunction with other tests to further validate performance.

💭  Looking into

A comparison of performance and ease-of-use between the 3 most popular Rust frameworks

💭  Looking into

The top 3 Rust frameworks by popularity and why they are well-regarded