Building Web APIs with Rust
State of the Union
Rainer Stropek | @rstropek@fosstodon.org |Β @rstropek
Introduction
Rainer Stropek
- Passionate software developers for 25+ years
Β - Microsoft MVP, Regional Director
Β - Trainer, Teacher, Mentor
Β - π community
Why? How?
Why This Session?
- Rust π¦ is becoming more and more popular
- People from other languages/platforms are coming on board
- Rust is used in more areas of software development (e.g. APIs)
Β
- Many Web API-related frameworks for Rust
- Where to start?
- What to use?
Β
- Guide through Rust's rich and diverse web API ecosystem π
- No deep dive, no exhaustive market analysis, an overview
- Share personal experiences and opinions
- Provide a starting point for a deeper, project-specific research
How Did I Go About it?
- A personal selection of four web API frameworks for Rust
- My selection criteria
- Widely used (huge number of downloads according to crates.io)
- Feature-rich for developing RESTful web APIs
- Based on tokio
- Builds with stable Rust
- Personal interests and preferences
Β
- If your favorite framework is missing, I apologize
- We only have limited timeβ
- Not mentioning a framework does notΒ say anything about its quality!
Agenda
fn main() {
for framework in ["Actix Web", "Rocket", "Warp", "Axum"] {
quick::intro(framework);
look_at::some_code(framework);
personal::statement(framework);
}
summary::<closing>();
}
About Actix Web
- Well-established, well maintained
- Exists for many years, with new releases every few months
- Currently in version 4.3
- Feature-rich (including WebSockets)
Β
- Known to be fast β‘
- I did not do benchmarks
- Benchmarks depend on many factors
- However, results in Techempower Benchmarks are impressive ππ»
Demo
Time!
My Thoughts About Actix Web
- Easy to learn
- Experienced web developer? You will feel at home pretty quickly
Β
- Experienced web developer? You will feel at home pretty quickly
- I like the API and the programming model
- Everything is typed
Β
- Everything is typed
- Documentation ππ»
- Documentation is available
- Large selection of examples for various use-cases
β
- So?
- Not my personal favorite, but I would enjoy doing a project with it
About Rocket
- Well-established, well maintained
- Exists for many years, quite long since the last non-RC version
- Currently in version 0.4.10, but 0.5.0-rc.2 available
- Feature-rich (including Diesel support, but no WebSockets)
Β
- Claims to be simple, "batteries included" - which it is on my opinion
Demo
Time!
My Thoughts About Rocket
- Easy to learn, even easier than Actix Web
- Experienced web developer? No problem getting started!
Β
- Experienced web developer? No problem getting started!
- I like the API and the programming model
- Everything is typed, but you shouldn't be allergic to macros π
Β
- Everything is typed, but you shouldn't be allergic to macros π
- Documentation ππ»ππ»
- Documentation is available and quite detailed (incl. 0.5 RC)
- Large selection of examples for various use-cases
β
- So?
- Used it, π it
- Eagerly awaiting 0.5 and following versions
Warp
About Warp
Demo
Time!
My Thoughts About Warp
- Interesting π€, intellectually challenging for me
- I have seen quite a few frameworks, but Warp's filters are new to me
Β
- I have seen quite a few frameworks, but Warp's filters are new to me
- Personally, I do not like the programming model and API so much
- Super long and complex types make working with Warp difficult
Β
- Super long and complex types make working with Warp difficult
- Documentation is available but could be enhanced
- Primarily API documentation, not so much conceptual docs
- Examples are available, fill some gaps of the docs
β
- So?
- Interesting, but personally I would not use it in a new project
Axum
About Axum
- Rather young, but getting quite some attention
- New versions every few months
- Currently in version 0.6.7 available
- Relies heavily on tower/tower-http, no custom middleware system
Β
- No Macros π
Β - Seems to be fast β‘
- Like with Actix, Techempower BenchmarksΒ are impressive ππ»
Demo
Time!
My Thoughts About Axum
- My current favorite in terms of Rust web API frameworks
- π the API
-
π the tight integration with other Tokio crates
Β
- Documentation is available but could be enhanced
- Primarily API documentation, not so much conceptual docs
- Large and very helpful selection of examples for various use-cases
Β
- So?
- Looking forward to doing first real-world projects with it
What about...
Spin
Demo
Time!
My Thoughts About Spin
What an awesome future π€©!
But a tiny bit too early for production π
So?
So?
- You have choices π
- You must make a choice π€
β
- You must make a choice π€
- Rust for web API development?
- Definitely works!
β
- Definitely works!
- Are we at par with other platforms (e.g. ASP.NET Core)?
- No, not yet. They have more features and offer similar perf.
- Sweet spot: Web APIs that benefit from Rust's unique features
(e.g. performance, resource efficiency, featureful language)
β
- Most importantly: Is it fun? Is it enjoyable?
- Oh yeah, it definitely is π₯³π
Building Web APIs with Rust
Q&A
Rainer StropekΒ | @rstropek@fosstodon.org |Β @rstropek
Web API Development with Rust - State of the Union
By Rainer Stropek
Web API Development with Rust - State of the Union
Rust is a great platform for building small and fast web APIs. In this talk, Rainer compares the most popular framework options for web APIs written in Rust and speaks about pros and cons.
- 1,256