DEV Community


Posted on

Two diagrams showing the current Rust network ecosystem

Today I drew two diagrams to show the current Rust Web ecosystem.

tokio ecosystem

Alt Text

As you can see from the diagram, the tokio ecosystem is now complete with the basic core components for web services and web development. Especially with the introduction of the Axum framework, tokio is close to being complete in the Web ecosystem.

Axum's middleware uses the tower abstraction directly, which has the following advantages:

  1. the use of a unified Service and Layer abstraction standards, to facilitate everyone to prosper the ecology
  2. reuse the tokio / hyper / tonic ecosystem

axum's routing mechanism does not use property macros like rocket, but provides a simple DSL (chain call). Routing is based on iterations and regular expressions to match, and routing performance should be similar to actix-web.

A convenient extractor is also provided, as long as FromRequest is implemented it is an extractor and very easy to implement.

There are also some others advantages.

In a word, Axum is, in my opinion, a milestone for Rust in the Web development field, and it strongly drives the tokio/tower ecosystem. It's not quite mature yet, but it has a lot of potential.

Others Web Frameworks

Alt Text

actix-web itself adds a layer of runtime threads as Actor to manage multiple threads, each thread is actually running a tokio single thread block_on , so that between the threads can not task stealing , lost the advantages of tokio task scheduling , in exchange for the performance of wireless thread context switching . This is the main difference between actix-web and other frameworks. actix-web's middleware also borrows from Tower Service, but it is not as generic as tower.

The advantage of rocket is a well-developed API, especially for handling forms very well. Unlike other frameworks, rocket has strong constraints on middleware in order to achieve security and correct goals, and it is not as free to implement middleware as Axum. This also predestines it to be more difficult to form an generic ecosystem. rocket is not performance oriented at the moment, maybe it will be optimized for performance in the future after 1.0.

How to choose your own web framework, combined with your scenario and preferences to choose it.

Top comments (1)

imbolc profile image

though my simple tests showed Rocket-rc1 to have roughly the same performance as Axum