Skip to content

d-unsed/rust_sidekiq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

  1. 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
  1. Install sidekiq gem
$ bundle install
  1. Push some Sidekiq jobs to the queue
$ bundle exec ruby bin/push.rb
  1. Start rust_sidekiq server
$ bundle exec ruby bin/server.rb
  1. 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!

About

An example of simple sidekiq-compatible server

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published