Slide 1

Slide 1 text

Blazing Fast Microservices in Rust and Docker ALEXEY NOVAKOV, ULTRA TENDENDCY, MARCH 2020

Slide 2

Slide 2 text

Rust - System programming language focused on safety and performance - Syntactically like C++ - No explicit runtime - No Garbage Collector and no manual memory management like in C

Slide 3

Slide 3 text

Applications of Rust today

Slide 4

Slide 4 text

Web development, WebAssembly Command line utilities Games Operating Systems Networking Microcontroller programming Microservices (Cloud) Not for Big Data yet

Slide 5

Slide 5 text

Build Tool and Crates ◦ Cargo.toml: [package] name = "data-gen" version = "0.1.0" [dependencies] rand = "0.7.3" chrono = "0.4" serde = "1.0" serde_derive = "1.0" job_scheduler = "*"

Slide 6

Slide 6 text

What is great in Rust - Fast startup and small binary size - Generics and Traits - Explicit immutable vs. mutable aspect - Pattern Matching - Compiler Error Messages - Fast compilation if you come from JVM - No Null - No classes pub trait Formatter { fn fmt(&self) -> String; } 
 impl Formatter for &str { fn fmt(&self) -> String { "[string: ".to_owned() + &self + "]" } }

Slide 7

Slide 7 text

What is not so great in Rust - Dealing with "borrow checker" errors - No High-Order Types - Too verbose C++ like syntax, if you come from Scala or Haskell (semicolons, curly braces, lambdas )

Slide 8

Slide 8 text

Use Case - Generate Random Data - Insert Data into Postgres database based on Cron expression - Run as Docker container

Slide 9

Slide 9 text

Crates •diesel •serde_derive •job_scheduler •rand •chrono

Slide 10

Slide 10 text

Results • Docker image Size: 7.79MB • Startup: 0m0,061s docker logs 35f048a38722 [2020-03-24T11:03:13Z INFO data_gen] starting up [2020-03-24T11:03:13Z INFO data_gen] Data Generation Job scheduled with: 1/10 * * * * * [2020-03-24T11:03:21Z INFO data_gen] Generated records: 12 [2020-03-24T11:03:31Z INFO data_gen] Generated records: 7

Slide 11

Slide 11 text

Go to the Code https://github.com/novakov-alexey/data-gen

Slide 12

Slide 12 text

Thank you! Questions? Alexey Novakov email: - alexey.novakov at ultratendency.com - novakov.alex at gmail.com Blog: https://medium.com/se-notes-by-alexey-novakov https://novakov-alexey.github.io/ Code: https://github.com/novakov-alexey Twitter: @alexey_novakov