Zero to production in Rust

Zero to production in Rust - a book for the Rust practitioner

TLDR

For the last 3 months I have been working with the book Zero to production in Rust and learned a lot. It is not a book to learn the language but how to use the Rust ecosystem in a professional setup.

Tip

I highly recommend buying the book or donating to Luca as he really must have spent a huge amount of time writing this excellent content - there is even a student discount and a discount for poorer regions of the world.

However, if you first want to get a feel for whether this book is for you you can also follow a selection of chapters on [Luca`s blog](https://www.lpalmieri.com/posts/2020-05-24-zero-to-production-0-foreword/)

What is this book about

This is not a book about learning the Rust programming language, there are other excellent books about the language itself.

Instead the book develops an end-2-end real world web application (newsletter subscription app) to introduce you to the Rust ecosystem:

  • project structure
  • unit and integration testing
  • build setup
  • dockerised builds
  • continuous integration with github actions including formatting (cargo format), linting (clippy), security dependency checking (cargo audit), test code coverage (tarpualin)

The book uses a select, well-integrated subset of the Rust crates relevant to a web application with HTML form frontends and an async backend with persistence

  • actix-web
  • tokio async runtime
  • postgres database for domain data
  • redis key-value store for session data
  • reqwest for REST clients (called from the backend)
  • and numerous other crates required for the example use case which integrate well with the actix async model

The book also shows you how to deploy your application in a production environment

  • using DigitalOcean as a platform to run the databases and containers
  • using Postmark’s REST API as a back-end to send out the newsletters and subscription confirmation emails

Each step in the development of the sample project expands on the previous section.
There is a Github branch for each chapter available so that you can also focus and start with individual chapters if you want and don’t have the time to go through all the content.

My learning experience

I think I spent about 60 hours completing the book, following all the steps in my own development environment and doing most of the optional exercises.
Sometimes I deviated from the book and used more recent versions of the crates - this resulted in subtle bugs that I hat to debug to get the test cases green again, which was perhaps the most rewarding learning experience.

I would highly recommend the book to those who think they have already learned the language but have not yet worked with Rust in a professional environment.
Even if you have done CI/CD pipelines and container deployments with other languages and frameworks you will learn a lot of Rust specific things like multi-stage Docker builds with “chef” to drastically reduce build times.

I kept track of my progress in my own github repo.
Some readers may find it useful to update the examples to more recent versions of the Rust crates - the book was written in 2020/2021 and some crates needed to be updated - for example to get rid of security vulnerabilities or build problems that were found/created after the book was published.