Add embedded puma example

This commit is contained in:
Mike Perham 2022-09-08 09:56:35 -07:00
parent 5f0c9bc7b6
commit 19047b9cd0
No known key found for this signature in database
3 changed files with 22 additions and 1 deletions

View File

@ -41,4 +41,4 @@ The standard Ruby runtime does not scale well with lots of Threads so embedded m
> RULE OF THUMB: **if you are using embedded mode, you should be monitoring the CPU usage of that process!**
Note the other Threads enumerated above. The concurrency value controls how many Processor threads will be started but there are also separate threads for heartbeat, poller, manager and other internal services. These threads are relatively CPU-light but they still need regular, predictable access to the CPU for their own work.
Note the other Threads enumerated above. The concurrency value controls how many Processor threads will be started but there are also separate threads for heartbeat, scheduler, and other internal services. These threads are relatively CPU-light but they still need regular, predictable access to the CPU for their own work.

View File

@ -15,6 +15,10 @@ module Sidekiq
fire_event(:startup, reverse: false, reraise: true)
@launcher = Sidekiq::Launcher.new(@config)
@launcher.run
sleep 0.1
logger.info "Embedded mode running with #{Thread.list.size} threads"
logger.debug { Thread.list.map(&:name) }
end
def quiet

17
myapp/config/puma.rb Normal file
View File

@ -0,0 +1,17 @@
require "sidekiq/cli"
workers 3
threads 3, 5
on_worker_boot do
$sidekiq = Sidekiq.configure_embed do |config|
config.queues = %w[critical default low]
# don't raise this unless you know your app has available CPU time to burn.
# it's easy to overload a Ruby process with too many threads.
config.concurrency = 2
end
$sidekiq&.run
end
on_worker_shutdown do
$sidekiq&.stop
end