Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sidekiq_process_killer

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sidekiq_process_killer

  • 0.4.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

SidekiqProcessKiller

Build Status

When you have memory leaks or "bloats" in your ruby application, identifying and fixing them can at times be a nightmare. Instead, an "acceptable" mitigation is to re-spin the workers. Its a common technique that can be found in Puma Worker Killer or Unicorn Worker Killer. Though, its neater and good practice to find and fix your leaks.

SidekiqProcessKiller plugs into Sidekiq's middleware and kills a process (by sending SIGTERM) if its processing beyond the supplied RSS threshold. Since this plugs into the middleware, the check is performed after each job.

Installation

While in testing period, this is not published to a public server, yet. Until then:

Add the following to your Gemfile

  gem "sidekiq_process_killer", git: "git://github.com/shayonj/sidekiq_process_killer.git"

Usage

Configuration

memory_threshold: 250.0 # mb
silent_mode: false
statsd_klass: nil
Config nameDescription
silent_modeWhen set to true, no signal will be sent to running process. This is helpful if you are planning to launch this, but want to first do a dry run.
memory_thresholdWhen current RSS is above this threshold, the respective Sidekiq worker will be instructed for termination (via TERM signal, which sidekiq gracefully exits).
statsd_klassThis is a class object which responds to an increment. If present, the increment function will be called with a single argument of type Hash which contains, metric_name, worker_name and current_memory_usage. This class is called when attempting to terminate a process or if the process had to be forcefully be terminated.

Updating default configuration:

class CustomMetric
  ...

  def increment(params)
    StatsD.count(
      params[:metric_name],
      tags: {
        worker_name: params[:worker_name]
      }
    )
  end

  ...
end

SidekiqProcessKiller.config do |con|
  con.memory_threshold = 1024.0
  con.silent_mode = false
  con.statsd_klass = CustomMetric.new # your custom statsd class object
end

Turn on SidekiqProcessKiller

Just plugin the Middleware

Sidekiq.configure_server do |config|
  config.server_middleware do |chain|
    chain.add SidekiqProcessKiller::Middleware
  end
end

The class tries to log as much as possible, as best as possible.

FAQs

Package last updated on 22 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc