Skip to content

Enable sidekiq job limits by default through application configuration

Bob Van Landuyt requested to merge bvl-sidekiq-job-limit-config into master

What does this MR do?

This allows configuring Sidekiq job limits from the admin area, or using the API.

Configuration options are:

Limiter mode*

sidekiq_job_limiter_mode, this can either be track (0), or compress (1).

In track mode, this will only report errors when the arguments for jobs exceed the sidekiq_job_limiter_limit_bytes option. But no jobs will be compressed or rejected.

In compress mode, the jobs will be compressed before they are stored in Redis. If a job's arguments would still exceed sidekiq_job_limiter_limit_bytes after compression an exception would be raised and the job would not be stored in Redis. Setting the sidekiq_job_limit_bytes to 0 avoids raising an error.

Jobs will get compressed or rejected when they are scheduled.

Default is compress.

Compression threshold bytes

When the job's arguments exceed this size, the job's arguments will be compressed before storing them in Redis. Below this size, nothing will happen.

Default is 100Kb.

Size limit

When jobs exceed this size after compression, an exception will be raised preventing the jobs from being stored in redis.

Default is 0 bytes.

The defaults will enable job-compression without limiting for self-managed installations. Compression has been running on GitLab.com. On GitLab.com we're rejecting jobs exceeding 5MB after compression.

The validation is entirely skipped for BackgroundMigrations, since the scheduling of those cannot depend on the state of the schema. So we cannot load the settings into memory to run the clientside validation.

Changelog: added

For gitlab-com/gl-infra/scalability#1177 (closed)

Screenshots or Screencasts (strongly suggested)

image

Migration output

== 20210825090535 AddSidekiqLimitsToApplicationSettings: reverting ============
-- remove_column(:application_settings, :sidekiq_job_limiter_limit_bytes, :integer, {:default=>0, :null=>false})
   -> 0.1438s
-- remove_column(:application_settings, :sidekiq_job_limiter_compression_threshold_bytes, :integer, {:default=>100000, :null=>false})
   -> 0.0034s
-- remove_column(:application_settings, :sidekiq_job_limiter_mode, :smallint, {:default=>1, :null=>false})
   -> 0.0197s
== 20210825090535 AddSidekiqLimitsToApplicationSettings: reverted (0.1723s) ===

== 20210825090535 AddSidekiqLimitsToApplicationSettings: migrating ============
-- add_column(:application_settings, :sidekiq_job_limiter_mode, :smallint, {:default=>1, :null=>false})
   -> 0.0344s
-- add_column(:application_settings, :sidekiq_job_limiter_compression_threshold_bytes, :integer, {:default=>100000, :null=>false})
   -> 0.0097s
-- add_column(:application_settings, :sidekiq_job_limiter_limit_bytes, :integer, {:default=>5000000, :null=>false})
   -> 0.0116s
== 20210825090535 AddSidekiqLimitsToApplicationSettings: migrated (0.0561s) ===

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Edited by Bob Van Landuyt

Merge request reports