Awesome
Rust Sidekiq server
Description
An example of simple sidekiq-compatible server which performs Sidekiq jobs.
This server does not require to change any Ruby code, neither for pushing jobs to queues nor for using workers.
Performace
-
Both servers were run in Single-threaded mode
-
Simple workers were used to compare only the speed of fetching jobs, but not the performance of Ruby workers themselves.
10000 jobs
sidekiq - 3.42 sec
rust_sidekiq - 0.94 sec (~3.63 times faster)
Technologies
- Rust to write native extension
- Sidekiq to push jobs (simulate the real Ruby application)
- Ruru to allow Rust to communicate with Ruby (declare classes, run workers etc)
Current limitations
-
String
arguments for jobs -
Single-threaded
Usage
- Compile Rust library
$ cd ext/rust_sidekiq
$ cargo build --release
$ cd ../..
Mac OS X only:
cp ext/rust_sidekiq/target/release/librust_sidekiq.dylib ext/rust_sidekiq/target/release/librust_sidekiq.bundle
- Install
sidekiq
gem
$ bundle install
- Push some Sidekiq jobs to the queue
$ bundle exec ruby bin/push.rb
- Start
rust_sidekiq
server
$ bundle exec ruby bin/server.rb
- You can also push another 10k jobs and start real Sidekiq server
$ bundle exec ruby bin/push.rb
$ bundle exec sidekiq -r ./lib/worker/printer.rb -c 1
Special thanks go to Julien Blanchard whose article inspired for creating this example with both Rust and Ruby!