Slide 1

Slide 1 text

Rust in production Matthias Endler

Slide 2

Slide 2 text

What is Rust?

Slide 3

Slide 3 text

https://www.erps.com.au/what-is-rust

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

Output:

Slide 7

Slide 7 text

Me explaining Rust’s ownership & borrowing, lifetimes, generics and expression syntax You

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

About Rust Research project at Mozilla 2006 2015 Version 1.0 2017 First Rust code in Firefox 2021 Rust Foundation 2024 3.7 million Rust users

Slide 14

Slide 14 text

My rust experience ● Using Rust since 2015 ● Rust Cologne User Group ● “Hello Rust” YouTube channel ● Open Source work ● Rust consultancy ● Rust in production since 2020

Slide 15

Slide 15 text

Why was rust created? ● C + + code in Firefox had many security issues. ● Multithreaded code is hard to write with C + + (data races).

Slide 16

Slide 16 text

Rust vs other languages Source: Jon Gjengset - Considering Rust

Slide 17

Slide 17 text

vs Python Much faster. Much lower memory use. Multi-threading. Algebraic data types. Pattern matching. Comprehensive static typing, so: Many fewer runtime crashes.

Slide 18

Slide 18 text

vs C/C++ No segfaults. No buffer overflows. No null pointers. No data races. Powerful type system. Unified build system. Dependency management.

Slide 19

Slide 19 text

vs Go No GC pauses; lower memory use. No null pointers. Nicer error handling. Safe concurrency. Stronger type system. Zero-cost abstractions. Dependency management.

Slide 20

Slide 20 text

vs Java No JVM overhead or GC pauses. Much lower memory use. Zero-cost abstractions. ConcurrentModificationException Pattern matching. Unified build system. Dependency management.

Slide 21

Slide 21 text

vs Javascript Multi-threaded by design Stronger typesystem Static typing No runtime overhead Unified build system Zero-cost abstractions

Slide 22

Slide 22 text

comparison rust java go JS/TS Community size Small Large Medium/Large Large ecosystem Small Large Medium Large Operational cost Low High Medium Medium Safety High Low/Medium Low/Medium Low/Medium Performance High Medium Medium Low Tooling Good Okay Okay Okay Complexity High Medium Low Low

Slide 23

Slide 23 text

Tangent: Java runtime behavior Java application Java runtime

Slide 24

Slide 24 text

Tangent: Java runtime behavior Java application Java runtime container

Slide 25

Slide 25 text

Tangent: Java runtime behavior Java application Java runtime container Virtual machine

Slide 26

Slide 26 text

Tangent: Java runtime behavior

Slide 27

Slide 27 text

Tangent: Java runtime behavior Time CPU usage Bootup Jvm optimizations

Slide 28

Slide 28 text

Rust’s strengths

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

“ The reason that people use Rust is because actually it's better for building more reliable systems. Niko Matsakis, Lead of Rust Language Design Team

Slide 31

Slide 31 text

Discord: switching from go to rust https://discord.com/blog/why-discord-is-switching-from-go-to-rust Rust Go

Slide 32

Slide 32 text

Rust vs golang vs java vs python https://medium.com/star-gazers/benchmarking-low-level-i-o-c-c-rust-golang-java-python-9a0d505f85f7

Slide 33

Slide 33 text

Aws: Rust’s impact on serverless pricing

Slide 34

Slide 34 text

Vulnerabilities in Firefox over time

Slide 35

Slide 35 text

Vulnerabilities in Firefox over time Rust introduced

Slide 36

Slide 36 text

https://docs.google.com/spreadsheets/d/1flUGg6Ut4bjtyWdyH_9emD9EAN01ljTAVft2S4Dq620

Slide 37

Slide 37 text

Security issues are a very real problem ● Google ○ Chromium project finds that around 70% of serious security bugs are memory safety problems ● Microsoft ○ 70% of bugs are memory safety issues ○ Each bug costs $150,000 to fix ○ > 70 Million Dollars for fixing those bugs (in 2018 )

Slide 38

Slide 38 text

Relative cost to fix bugs based on time of detection

Slide 39

Slide 39 text

Bugs detected during development cycle

Slide 40

Slide 40 text

Energy consumption

Slide 41

Slide 41 text

Rust’s weaknesses

Slide 42

Slide 42 text

Rust weaknesses ● Immature ecosystem ● Async/await support still very basic ● Lack of developers ● Learning curve ● Compile times

Slide 43

Slide 43 text

Learning curve

Slide 44

Slide 44 text

“ 50% of developers were productive in Rust after 4 months Google

Slide 45

Slide 45 text

“ It takes several weeks of hard effort Microsoft

Slide 46

Slide 46 text

RUST you

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

Size of programming communities 2023

Slide 49

Slide 49 text

Rust users

Slide 50

Slide 50 text

Major rust usage ● Linux Kernel ● Windows Kernel ● AWS Firecracker ● Dropbox storage layer ● Deno ● Turbopack ( Webpack) ● Figma ● Cloudflare

Slide 51

Slide 51 text

Major rust usage ● Linux Kernel ● Windows Kernel ● AWS Firecracker ● Dropbox storage layer ● Deno ● Turbopack ( Webpack) ● Figma ● Cloudflare ● Yes, and Crypto

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

No content

Slide 57

Slide 57 text

No content

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

https://twitter.com/gamaspace

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

You RN

Slide 64

Slide 64 text

A Case for Your company?

Slide 65

Slide 65 text

Strategies for Rust adoption

Slide 66

Slide 66 text

Popular ways of Rust integration ● Network APIs ○ Microservices ○ GraphQL ● Foreign-Function Interface ( FFI ) ○ Java ○ Python ○ C + + ● WebAssembly ○ Frontend ○ Plugin-systems

Slide 67

Slide 67 text

Rust Adoption in Network APIs Backend Service 1 Backend Service 2 Backend Service 3 API

Slide 68

Slide 68 text

Rust Adoption in Network APIs Backend Service 1 Backend Service 2 Backend Service 3 API 🐢

Slide 69

Slide 69 text

Rust Adoption in Network APIs Backend Service 1 Backend Service 2 Backend Service 3 API 🐢

Slide 70

Slide 70 text

Rust Adoption in Network APIs Backend Service 1 Backend Service 2 Backend Service 3 API

Slide 71

Slide 71 text

Rust Adoption in monoliths

Slide 72

Slide 72 text

Rust Adoption in monoliths

Slide 73

Slide 73 text

Rust Adoption in monoliths

Slide 74

Slide 74 text

Rust Adoption in monoliths

Slide 75

Slide 75 text

No content

Slide 76

Slide 76 text

Source VS RUST java

Slide 77

Slide 77 text

java ⏱ 7 days 🤑 $1100/run Source RUST ⏱ 1 day 🤑 $80/run VS

Slide 78

Slide 78 text

Rust adoption in hs-web-app

Slide 79

Slide 79 text

Rust integration in frontends / javascript

Slide 80

Slide 80 text

Requirements for adoption

Slide 81

Slide 81 text

Rust adoption needs a catalyst for success

Slide 82

Slide 82 text

Performance is a weak Catalyst 4x performance boost https://blog.consol.de/software-engineering/web-application-development/rust-vs-quarkus-native-vs-spring-native/

Slide 83

Slide 83 text

Performance is a weak Catalyst 1.5x performance boost https://blog.consol.de/software-engineering/web-application-development/rust-vs-quarkus-native-vs-spring-native/

Slide 84

Slide 84 text

GraphQL Case-Study

Slide 85

Slide 85 text

GraphQL Case-Study

Slide 86

Slide 86 text

1.The chosen project determines the odds of successful Rust adoption. ( Choose wisely)

Slide 87

Slide 87 text

Finding your first project for rust 1. Fix Pain Points Ideal for performance or concurrency issues. 2. Limit Scope Choose an impactful yet medium-sized projects. 3. Play Rust’s Strengths Find projects benefiting the most from lower operational costs and stability.

Slide 88

Slide 88 text

Recruiting is hard and expensive. Train your own people. ( Or hire me to do it)

Slide 89

Slide 89 text

Adopting rust 1. Identify Project Select a meaningful project for Rust implementation. 2. Team Assessment ○ Do not hire new staff specifically for Rust. ○ Evaluate the current team's readiness: ■ Check for hidden Rust experts. ■ Consider experience in languages similar to Rust. ( Java, Kotlin, C + + ) ■ Gauge the team's willingness to learn Rust. 3. Upskilling the Team ○ Self-guided learning using books and hands-on exercises. ○ Organize training workshops. ○ Team augmentation for asking harder questions. ○ Code reviews to improve the codebase.

Slide 90

Slide 90 text

You need a Long-Term mindset ( Think: years)

Slide 91

Slide 91 text

● Reduce operational costs ● Predictable performance ● Enable faster development cycles ● Less friction between dev and ops ● Developer happiness (most loved language for 7 years in a row) ● Gradual adoption possible benefits ● No quick wins ● Steep learning curve ● Long build times (locally and in CI ) ● Custom libraries required ● Need to write integrations with existing code Risks

Slide 92

Slide 92 text

corrode.dev/podcast

Slide 93

Slide 93 text

No content

Slide 94

Slide 94 text

corrode.dev/podcast