How I Build a Rust Backend Service

Here’s everything I’ve learned since the start of 2021

Kraig McFadden
Rust in Production

--

Photo by Lala Azizli on Unsplash

In early 2021, I built a prototype Rust backend service at work. I knew Rust was powerful and ergonomic. It could fly through difficult computation and language features like pattern matching and idiomatic Result and Option enums made it fresh, new, and exciting.

Honestly, it's a language that's hard not to fall in love with. But I had only used it then for game development, so it was a big change to serve a REST API, publish and consume Kafka messages, and talk to a database. On top of that, it seemed like no one else was using Rust for web applications.

The weekly newsletter, This Week in Rust, still described Rust as a "systems language" (though the description did change later that year). There was a lot of trailblazing to do. Here's everything I learned and how I build Rust backend services now.

Architectural Philosophy

The first thing to recognize is that Rust isn’t going to hold your hand on the big-picture architecture of your application. If you’re writing an application in Java, odds are you’re using a framework like Spring Boot, which provides some guidance for laying out your code. Or if you’re writing Ruby, you’ll probably use Rails.

--

--

Kraig McFadden
Rust in Production

Staff backend software engineer. Pursuing an MDIV at Reformed Theological Seminary. Princeton 2018 - Electrical Engineering. Opinions are my own.