Can I run both enable_rolling_restart and start
nitzanav opened this issue · 2 comments
nitzanav commented
Hi,
Can I run both enable_rolling_restart and start?
Is this safe?
before_fork do
require 'puma_worker_killer'
PumaWorkerKiller.config do |config|
config.ram = 512 # mb
config.percent_usage = 0.98
end
PumaWorkerKiller.enable_rolling_restart # Default is every 6 hours
PumaWorkerKiller.start
end
schneems commented
I’m not sure. I think it should be ok. You running into problems?
DemonGiggle commented
I don't think it's a good idea.
In this case, you will have 3 threads to do reaping. Two are for rolling restart.
The two for rolling restart will perform its work within few seconds, which mean there exists a case as the following sequence shows (assume you have two puma workers here):
- rolling_restart_1 close the worker_1 and wait 1 minute (default)
- puma remove a dead worker (worker_1) from @Workers
- rolling_restart_2 check the @Workers list and currently, only one remains, but it still remove it, said worker_2
- puma continues its work, so it create a worker and inserted to @Workers
The problem is that there will be a short downtime before step 4 (if the worker takes longer to initialize, the downtime will increase)
Actually, it may still happen even if two reaper exists (one is for oom checker, and the other is for rolling restart)