Moving from Haskell Servant to Rust Axum

I have a couple of servers running Haskell servant. If you don’t know servant, it’s a package for defining APIs as Haskell types. It’s a nice way to define server and client APIs. If you like Haskell, definitely check it out.

Anyway, the servers are running in Docker containers on a VPS. Even though they are relatively small and handle simple things like basic auth, user accounts, simple business logic, etc., code updates can cause Docker rebuilbs to be painfully slow, even with caching. A fresh build takes up to 40 minutes. A cached build can be 10 to 30 minutes depending on how deep the change is.

I came across this comment on Hacker News and started thinking about testing other ecosystems. I have used a bit of Rust in the past so I decided to migrate one server from Haskell servant to Rust axum. The main concern was keeping code high quality so I used Rust’s linter, Clippy, and ported over all the unit tests I had in Haskell to Rust. I also used Docker to build the project. Currently a fresh build is about 15 minutes as opposed to Haskell’s 40 minutes. I did have to give up some type safety, but for small servers with relatively simple business logic, it is not a huge loss.

I will launch the service this week. I’ll report back in a month or so on my experiences in production.