Skip to content

Instantly share code, notes, and snippets.

@DCrow
Last active July 11, 2018 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DCrow/8b7362c70eea0bdc6f3f3a77c15797ab to your computer and use it in GitHub Desktop.
Save DCrow/8b7362c70eea0bdc6f3f3a77c15797ab to your computer and use it in GitHub Desktop.
Sidekiq cli threads
# Sidekiq process structure
# 1 main thread https://github.com/mperham/sidekiq/blob/master/lib/sidekiq/cli.rb#L104
# 1 heartbeat thread https://github.com/mperham/sidekiq/blob/master/lib/sidekiq/launcher.rb#L23
# 1 scheduled thread https://github.com/mperham/sidekiq/blob/master/lib/sidekiq/scheduled.rb#L63
# options[:concurency] manager threads https://github.com/mperham/sidekiq/blob/master/lib/sidekiq/manager.rb#L44
# If using sidekiq-scheduler gem
# 1 rufus scheduler thread https://github.com/jmettraux/rufus-scheduler/blob/master/lib/rufus/scheduler.rb#L537
# Some arbitrary number up to :max_work_threads https://github.com/jmettraux/rufus-scheduler/blob/master/lib/rufus/scheduler/jobs.rb#L332
# If using rails in development and using listen gem
# Some arbitrary number of listen processor threads https://github.com/jonleighton/spring-watcher-listen/blob/master/lib/spring/watcher/listen.rb#L24
# Some arbitrary number of fsevent threads https://github.com/thibaudgg/rb-fsevent/blob/master/lib/rb-fsevent/fsevent.rb#L38
# Dump thread info
def dump_thread_backtraces
Thread.list.each do |thread|
puts "Thread #{thread}"
thread.backtrace.each { |backtrace| p backtrace }
end
end
# Also useful when searching for problems
# https://gist.github.com/krasnoukhov/a036bb7bc8c8416e9481
# https://github.com/schneems/heapy
# Useful unix commands
# Num of threads(including ruby vm thread) `ps aux -T | grep -c "[s]idekiq"`
# Last log lines `cat log/sidekiq.log | tail -n 100`
# Truncate log `truncate -s 0 log/sidekiq.log`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment