Sidekiq: Cara Untuk Utilisasi Sidekiq di Multiple CPU Core.

Posted on Updated on

sidekiq

Sidekiq itu naon?
Menurut yg bikin, sidekiq adalah:

Simple, efficient background processing for Ruby.

Sidekiq uses threads to handle many jobs at the same time in the same process. It does not require Rails but will integrate tightly with Rails 3/4 to make background processing dead simple.

Sidekiq is compatible with Resque. It uses the exact same message format as Resque so it can integrate into an existing Resque processing farm. You can have Sidekiq and Resque run side-by-side at the same time and use the Resque client to enqueue jobs in Redis to be processed by Sidekiq.

At the same time, Sidekiq uses multithreading so it is much more memory efficient than Resque (which forks a new process for every job). You’ll find that you might need 10 200MB resque processes to peg your CPU whereas one 300MB Sidekiq process will peg the same CPU and perform the same amount of work.

Intinya, sidekiq itu semacam library/tools untuk membuat ‘worker’ yang berjalan di background dan yang support multi-threading dan horizontal scaling.

Gue punya satu tips yang mungkin berguna buat lu pada, karena keterbatasan dari MRI Ruby (ini istilah dari Ruby versi standard), 1 process/instance sidekiq hanya bisa menggunakan 1 cpu core. Meskipun lu set untuk buka 100 thread, tapi tetep aja cuma bakalan pake 1 cpu core secara defaultnya.

Nah gimana caranya supaya Sidekiq bisa di-utilize di semua core server yang sedang berjalan? Nah, ada 2 cara yg gue tau, yaitu:

  1. MRI Ruby – Jalanin multiple sidekiq process. So kalau lu punya server 8 core. so, misalnya lu bisa deh jalanin 8 process sidekiq dengan masing2 16 thread.
  2. jRuby – Kalau lu pake jRuby environment, 1 process sidekiq bisa langsung utilize all the cpu core, karena behaviornya Java memang bisa utilize multiple cpu core, keren ya? 🙂

Terus dari 2 cara diatas kira2 yang mana yg performancenya lebih kenceng? Your mileage may vary kayaknya sih ;))

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s