memcrsd memcached server implementation in Rust
memcrsd is a key value store implementation in Rust. It is compatible with binary protocol of memcached server.
Supported features and compatibility
To check compatibility with memcached server implementation memcrsd project is using memcapable tool from libmemcached library
Here is a capability status for memcrsd:
./memcapable -h 127.0.0.1 -b -p 11211
Hostname was provided.127.0.0.1
binary noop [pass]
binary quit [pass]
binary quitq [pass]
binary set [pass]
binary setq [pass]
binary flush [pass]
binary flushq [pass]
binary add [pass]
binary addq [pass]
binary replace [pass]
binary replaceq [pass]
binary delete [pass]
binary deleteq [pass]
binary get [pass]
binary getq [pass]
binary getk [pass]
binary getkq [pass]
binary incr [pass]
binary incrq [pass]
binary decr [pass]
binary decrq [pass]
binary version [pass]
binary append [pass]
binary appendq [pass]
binary prepend [pass]
binary prependq [pass]
binary stat [pass]
All tests passed
Bug reports
Feel free to use the issue tracker on github.
If you are reporting a security bug please contact a maintainer privately. We follow responsible disclosure: we handle reports privately, prepare a patch, allow notifications to vendor lists. Then we push a fix release and your bug can be posted publicly with credit in our release notes and commit history.
Website
Testing
memcrsd project is tested using different types of tests:
- unit testing,
- fuzzy testing,
- end-2-end tests
Fuzzy testing
At the moment decoding network packets is fuzzy tested.
Generating test coverage reporting
To generate test coverage there is a convenient shell script that compiles and executed unit tests:
cd memcrs
./coverage.sh
firefox ../target/debug/coverage/index.html
The plan in the future is to have coverage ~90%.
Integration testing
For end-to-end integration testing at the moment memcrsd project is using memcapable tool from libmemcache library. In the future memclt binary will be used to perform end-to-end tests.
Measuring performance
Measuring performance can be tricky, thats why to measure performance memcrsd project is using industry standard benchmarking tool for measuring performance of memcached server which is memtier_benchmark. This tool can be used to generate various traffic patterns. It provides a robust set of customization and reporting capabilities all wrapped into a convenient and easy-to-use command-line interface. More information about memtier benchmark tool can be found on RedisLabs blog.
Memtier benchmark installation
Memtier benchmark is available on github, it needs to be cloned and compiled:
git clone https://github.com/RedisLabs/memtier_benchmark.git
autoreconf -ivf
./configure
make
make install
Generating flamegraph
To be able to sample and resolve Kernel functions:
- we need to expose kernel addresses(kptr_restrict)
- grant unprivileged users access to performance events in kernel(perf_event_paranoid)
sudo sh -c " echo 0 > /proc/sys/kernel/kptr_restrict"
sudo sh -c " echo -1 >> /proc/sys/kernel/perf_event_paranoid"
Generating flamegraphs:
sudo apt install -y linux-tools-common linux-tools-generic
cargo install flamegraph
cd ~/projects/memix
cargo flamegraph
cargo flamegraph --bin memcrsd
Attaching perf
By default release profile is built with debug symbols, see Cargo.toml:
[profile.release]
opt-level = 3
debug=true
On Ubuntu install required packages:
sudo apt install -y linux-tools-common linux-tools-generic
We can start a server:
./target/release/memcrsd -v & perf record -F 99 -p `pgrep memcrsd`
- First we run the memcrsd server and we send it to the background using the ampersand (&) symbol.
- Next to it, so it executes immediately, we run perf that receives the process identifier (PID) courtesy of pgrep memcrsd.
- The pgrep command returns the PID of a process by name.
After benchmarks are executed reports can be displayed using perf report:
perf report