Class: Gitlab::Memory::Watchdog::Configurator

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/memory/watchdog/configurator.rb

Constant Summary collapse

DEFAULT_PUMA_WORKER_RSS_LIMIT_MB =
1200
DEFAULT_SLEEP_INTERVAL_S =
60
DEFAULT_SIDEKIQ_SLEEP_INTERVAL_S =
3
MIN_SIDEKIQ_SLEEP_INTERVAL_S =
2
DEFAULT_MAX_STRIKES =
5
DEFAULT_MAX_HEAP_FRAG =

This disables the heap fragmentation check since it doesn’t work with Variable Width Allocation: gitlab.com/gitlab-org/gitlab/-/issues/407327

1
DEFAULT_MAX_MEM_GROWTH =
3.0
DEFAULT_SIDEKIQ_GRACE_TIME_S =

grace_time / sleep_interval = max_strikes allowed for Sidekiq process to violate defined limits.

900

Class Method Summary collapse

Class Method Details

.configure_for_pumaObject



20
21
22
23
24
25
26
# File 'lib/gitlab/memory/watchdog/configurator.rb', line 20

def configure_for_puma
  ->(config) do
    config.handler = Gitlab::Memory::Watchdog::Handlers::PumaHandler.new
    config.sleep_time_seconds = ENV.fetch('GITLAB_MEMWD_SLEEP_TIME_SEC', DEFAULT_SLEEP_INTERVAL_S).to_i
    config.monitors(&configure_monitors_for_puma)
  end
end

.configure_for_sidekiqObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/gitlab/memory/watchdog/configurator.rb', line 28

def configure_for_sidekiq
  ->(config) do
    # Give Sidekiq up to 30 seconds to allow existing jobs to finish after exceeding the limit
    shutdown_timeout_seconds = ENV.fetch('SIDEKIQ_MEMORY_KILLER_SHUTDOWN_WAIT', 30).to_i

    config.handler = Gitlab::Memory::Watchdog::Handlers::SidekiqHandler.new(
      shutdown_timeout_seconds,
      sidekiq_sleep_time
    )
    config.sleep_time_seconds = sidekiq_sleep_time
    config.monitors(&configure_monitors_for_sidekiq)
    config.event_reporter = SidekiqEventReporter.new
  end
end