'Production' deployment

Deploying software to production is much more than building a production-optimized binary. However, it is an important step, and the only step we'll cover in this chapter.

So far, we've been building unoptimized development builds. These are faster to build, but not optimized for speed or size.

One way of building an optimized version of your application, is to double-tap Ctrl and enter: cargo build --release from within RustRover.

Let's revert back to an earlier example and do just that:

fn greet(name: &str) {
    println!("Welcome, {name} to the Rust world!");
}

fn main() {
    greet("Rusty");
}

After compilation is complete we'll find our 'production'-ready binary in target/release as opposed to target/debug. This is where we'll discover one of the great aspects of Rust:

du -hs ./target/release/hello_rust_world                                                                                                                                 13:25:16  ☁  master ☂ ✭
280K	./target/release/hello_rust_world

Our optimized binary is 280KB in size!

Binary size will increase as our application becomes more complex and as we pull in more dependencies, but it will still be significantly smaller than many other high-level languages out on the market.

(Optimized) Rust code competes with C in terms of absolute speed: Benchmark games