Skip to content

Elect sidekiq-cluster leader

When using the SidekiqExporter via gitlab.monitoring.sidekiq_exporter.enable = true and running more than 1 worker in sidekiq-cluster, there is a race condition where all workers try to bind to a port to serve metrics and health-checks. We are currently using a workaround that let's all N-1 workers fail into a rescue clause when failing to allocate that port.

We can address this problem by letting sidekiq-cluster elect a "leader" of all workers, for instance sidekiq_0 (the first worker launched), which will take sole responsibility of the above. All other workers should not attempt to bind ports, serve metrics, or do anything of the sort.

In environments where only 1 worker is used, that worker will lead implicitly.

This makes for a more predictable environment where multiple sidekiq workers are present.

Edited by Matthias Käppler