Join us for a developer workshop where we’ll go hands-on to explore the affinities between Rust, the Tokio framework, and ScyllaDB. You’ll go live with our sample Rust application, built on our new, high performance native Rust client driver.
Build Low-Latency Applications in Rust on ScyllaDB
1. Piotr Sarna - Principal Software Engineer, ScyllaDB
Felipe Cardeneti Mendes - Solutions Architect, ScyllaDB
Andrew Brown - Director of Product Growth, ScyllaDB
Virtual Developer Workshop
Build Low-Latency
Applications in Rust on ScyllaDB
2. Presenters
2
Piotr Sarna
Piotr is a software engineer very keen on open-source projects, C++
and Rust.
Felipe Cardeneti Mendes
Felipe Mendes is an IT Specialist with years of experience with Linux. In
ScyllaDB, he works as a Solutions Architect
Andrew Brown
Andrew has been working with distributed systems in roles across
product development and product marketing.
4. IOT Rust Application Setup
$ git clone https://github.com/fee-mendes/rust-driver-example/
$ cd rust-driver-example/docker-compose
$ docker-compose up -d
$ docker exec -it rust-app /bin/bash
Minimum requirements:
- Linux or OSX x86
- Docker installed and setup
- Quadcore CPU
- 2 GB of memory available
- Windows is not supported
Join the #rust-driver channel on ScyllaDB Slack to discuss any issues or questions you might have.
5. Low latency, close
to hardware schedulers
Perfect horizontal & Vertical scale
5
1000 Nodes Cluster
2000 Cluster
K8S Deployment
60TB per Node 256 Cores per Node
1B Operations
per Second
About ScyllaDB: Fast and Scalable
7. + Asynchronous, non-blocking runtimes
+ Tokio: Most widely used Rust runtime
+ Seastar: C++ runtime for ScyllaDB
+ Fast, flexible, and reliable
+ Scalable, allows high concurrency and low latency
+ Green and sustainable
Why Rust? Why Tokio? Why ScyllaDB?
Rust Driver ScyllaDB
8. The effort started during a 2020 internal hackathon at ScyllaDB.
The existing CQL drivers (cassandra-cpp, cdrs) in the Rust ecosystem were not good
enough for us:
● Not fully async
● Unsatisfactory performance
● Not scalable enough
● Known, long-standing bugs
● No support for ScyllaDB-specific optimizations
○ e.g., Shard-per-core
● etc.
Some history
9. Our design goals:
● fully asynchronous
● token-aware, shard-aware
● ease of use
● maximizing performance
● minimizing overheads
● extensibility
● an extremely cool logo
Based on the principles above, we created the ScyllaDB Rust Driver.
Some history
10. ● Most popular async runtime, which should translate to best adoption
● It would be tempting to write the driver in a runtime-agnostic way, but
it's hard:
○ Not all API's are well defined yet
○ Tokio offers quite complete support for TCP communication,
timeouts and other useful abstractions
● Very actively developed
Why Tokio?
17. Rust ecosystem has a very convenient way of generating flamegraphs: cargo
flamegraph
Usage:
$ cargo install flamegraph
$ cargo flamegraph your-project
Profiling: cargo flamegraph
19. On Linux, flamegraph scripts use perf underneath. Perf is a well-known and very powerful
profiling tool with direct support in the kernel. Rust programs, since they're compiled via LLVM,
are perfectly capable candidates for profiling with perf.
Prerequisites:
Cargo.toml (the root one in case you use multiple workspaces):
[profile.release]
lto = false
debug = true
System (Linux-specific):
$ echo 0 | sudo tee /proc/sys/kernel/perf_event_paranoid
$ echo 0 | sudo tee /proc/sys/kernel/kptr_restrict
Profiling: perf
20. By the way, when run on Linux, cargo flamegraph leaves a side effect - a perf.data file,
which is a result format from calling perf record. Here's another example:
$ perf record -g ./target/release/metric-collector
$ perf report -g
Profiling: perf