DEV Community

Cover image for What we learned building our SaaS with Rust πŸ¦€

What we learned building our SaaS with Rust πŸ¦€

Gaspard Boursin on April 29, 2024

In this post we will not answer the question everybody asks when starting a new project: Should I do it in Rust ? Instead, we'll explore the pitf...
Collapse
 
gaspardb profile image
Gaspard Boursin Meteroid • Edited

Thanks for reading ! This was my first post ever, I'd love to have your feedback !

What should we write about next ?

  1. πŸ”₯Top libraries that boosted our productivity
  2. 🀯 Clean error propagation in Rust
  3. πŸ’– Top Rust open source projects we take inspiration from
  4. πŸš€ Building a SaaS with Rust + GRPC + React
  5. πŸ¦„ How we leveraged Clickhouse to build our dynamic Metering module

Or if you have suggestions, don't hesitate to let us know in comments !

Collapse
 
eli_glanz profile image
Eli

Choosing #5!

Collapse
 
robinbastien profile image
Robin Bastien • Edited

*#4 please! *
Mid-read I veered off and researched how one would approach this. Thank you for the article!

Collapse
 
best_codes profile image
BestCodes

Hmm… I'd say it's up to you (of course), and I can't really decide…
I guess I would choose 2 or 5.

Awesome article!

Collapse
 
jar profile image
Phil R.

I'd vote for 1 & 2

Collapse
 
bhirmbani profile image
Bhirawa Mbani

please do number 4 sir

Collapse
 
benbpyle profile image
Benjamen Pyle

Great article. I've been working to transition teams into Rust in the world of AWS Serverless with Lambda Functions and Containers. The learning curve is real but the productivity and performance is amazing.

Collapse
 
gaspardb profile image
Gaspard Boursin Meteroid

Thanks ! Serverless is a great use case for Rust yes, cold start diff can be huge ! What language are they coming from ?

Collapse
 
benbpyle profile image
Benjamen Pyle

So I work with a lot of different teams. Most come from Go but I've moved teams from TypeScript too.

Collapse
 
tombohub profile image
tombohub

do you mean productivity once you get over the learning curve? Where does this productivity come from? is it type safe code? easier error handling?

Collapse
 
benbpyle profile image
Benjamen Pyle

Fewer defects. Better project/library management. Cleaner code paradigms like errors and enums.

Collapse
 
gaspardb profile image
Gaspard Boursin Meteroid • Edited

The support following this post has been amazing, thanks everyone ❀️

We're now working on our deep dive series ✨

In the meantime if you want to start looking at some webdev projects, we did a tiny "listicle" with a couple of opensource saas/fullstack tools that have been invaluable to us while learning, I hope it can be useful to you as well πŸ™Œ
The projects that helped us learn Rust πŸ¦€
On a different theme, we published yesterday: What's coming to Postgres ? 🐘, a dive into the recent innovations in that space.
Cheers !

Collapse
 
curry44424 profile image
Curry44424

Great to hear I’m using rust in my backend as well it’s just crazy cause when I started like most Rust was foreign language people were knee deep in react and Ruby so to see rust take off is nuts future definitely bright in Rust

Collapse
 
gaspardb profile image
Gaspard Boursin Meteroid

Adoption from larger players and efforts from the community have made it a lot easier to onboard for a variety of use cases, and we're still early πŸ‘

Collapse
 
timibolu profile image
Oluwatimilehin Adesina

Thanks for this article. Amazingly, you're open-source. I will surely learn from the repo.
I am also learning rust. I built a basic backend with Axum and MongoDB. Unfortunately, I can't share -- client work. It was a bittersweet experience. I enjoyed some things but found other things stressful coming from a TypeScript/Golang and Python background. I am still learning though.

Collapse
 
gaspardb profile image
Gaspard Boursin Meteroid

Thanks ! I can relate, until you've truly integrated the concepts lifecycle and ownership can drive you crazy. It'll get easier with practice !

Collapse
 
ricardogesteves profile image
Ricardo Esteves

Cool, thanks for sharing it.
4 would be nice!

Collapse
 
vingitonga profile image
Vincent Gitonga

Wow.
I loved the article.
It's really encouraging and I think it's time I head back and learn rust πŸ˜‚.

Collapse
 
gaspardb profile image
Gaspard Boursin Meteroid

Thanks Vincent :) Join us πŸ¦€ πŸ¦€

Collapse
 
ddbb1977 profile image
Danny Boyd

Why not Scala? Since you were Scala developers what is the reason not to choose Scala?

I'm myself wondering if Scala is a dead end as moving to Scala 3, licensing problems with Akka/Pekko,, reduced community, ABI stability, and so on and I've been wondering if I should move to Rust.

I love coding in Scala, it's type system, hybrid OOP functional paradigm, JVM based and lot of other merits, but it feels like investing more time in it's ecosystem is not worth it.

I would love to hear why you've made the move over to Rust more than just the "drama-heavy and sometimes toxic Scala community". Do you see Scala as a technical dead end too?

Collapse
 
gaspardb profile image
Gaspard Boursin Meteroid

Hey Danny,
We had the same feeling as you. Although we really enjoyed the language, we didn't feel like committing to a long-term project based primarily on Scala, even if it meant starting from scratch in a new ecosystem. I wouldn't say that Scala is a dead end, but it has definitely lost its flavor for us, and starting this project was a good opportunity to change and have fun learning something new.

Collapse
 
december1981 profile image
Stephen Brown

I can't speak for the relational db drivers, but the mongodb rust driver is excellent, and quite mature.

Collapse
 
steeve profile image
Steeve

Great article, and it motivates me to start learning Rust (probably in a couple of days πŸ™„)...

Collapse
 
gaspardb profile image
Gaspard Boursin Meteroid

Thanks, first few weeks are hard but hang in there, it gets pretty rewarding afterward :)

Collapse
 
louaiboumediene profile image
Louai Boumediene

I've been exited to start learning rust since a long time, after this article... ITS JUST THE TIME!

Collapse
 
gaspardb profile image
Gaspard Boursin Meteroid

ahah happy to hear it πŸ˜„

Collapse
 
ashkanmohammadi profile image
Amohammadi2

2

Collapse
 
caniko profile image
Can H. Tartanoglu

Lovely! Will solo build a product in Rust very soon.

Collapse
 
gaspardb profile image
Gaspard Boursin Meteroid

Great ! Let us know how it goes :)

Collapse
 
jar profile image
Phil R.

Insightful post πŸ‘

Collapse
 
gaspardb profile image
Gaspard Boursin Meteroid

Glad you liked it πŸ™Œ

Collapse
 
jitenpalaparthi profile image
Jiten Palaparthi

This is awesome post

Collapse
 
gaspardb profile image
Gaspard Boursin Meteroid

Thanks Jiten ;)

Collapse
 
skadyan profile image
Sandeep Kadyan

Thanks for sharing your Rust experience. I found it a well-articulated article.

Collapse
 
gaspardb profile image
Gaspard Boursin Meteroid

Thanks Sandeep :)

Collapse
 
motedb profile image
mote

This resonates strongly with our experience building moteDB, an embedded multimodal database for AI agents and robots, also in pure Rust.

Your point about the ecosystem being "still maturing" is spot-on, but I'd frame it differently: Rust's ecosystem is mature where it matters most (core language, async runtime, serialization) and immature where it's expected to be (niche domain-specific libraries). We hit this exact wall when we needed a database that could handle vector embeddings, structured sensor data, and time-series logs in a single embedded engine β€” nothing existed that was both Rust-native and designed for edge AI workloads.

On lesson #4 ("don't chase perfection") β€” this cannot be overstated. Our first version had way too much unsafe code trying to squeeze out every last nanosecond from our B+ tree implementation. We ended up rewriting it with safe Rust, using Arc<RwLock<T>> in places where we initially thought we needed lock-free data structures. The result? Maybe 3-5% slower on microbenchmarks, but we shipped 3 months earlier and haven't had a single memory safety issue in production.

The one thing I'd add to your list: Rust's type system is your best testing tool. We model our storage engine's state machine using Rust's enum system, and the compiler catches invalid state transitions that would require dozens of unit tests in other languages. When you're dealing with crash recovery and WAL replay logic, having the compiler enforce that "you cannot transition from CRASHED to RUNNING without first calling RECOVER" is genuinely game-changing.

Also interesting to see you chose gRPC-web + Tonic. We went with a similar stack for our inter-process communication layer (when a robot's perception module needs to query the database). Tonic's codegen from protobuf specs is really clean.

Question for the team: how are you handling database migrations in production? We ended up building a custom schema evolution system since Diesel's migration tooling felt too heavy for embedded deployments. Would love to hear what approach worked for a SaaS-scale product.

Collapse
 
ankeshkapil profile image
Ankesh Kapil

Is it really worth it to move from java ecosystem to rust.Considering the effort it needs to migrate and also finding folks in rust is not possible so you need to give some time to devs to warm up. Also its not possible to achieve good productivity due to the lack of tooling.

Collapse
 
gaspardb profile image
Gaspard Boursin Meteroid

If you don't feel the need for your use case (or motivation), or if you have short-term productivity requirements, don't move to rust !
However regarding the tooling I must say it has been pretty straightforward (at least it is not something that impacted negatively our productivity)

Collapse
 
panjibaskoro profile image
Panji Iman Baskoro

love the article. the best part of rust is even the learning curve is really something but their documentation, their book even the ruslings is so great. Even better they do really know how to make error messages lol

Thank you for the articles, i'll refer anyone that start to learn rust to read this one <3