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