Enable sidekiq job limits by default through application configuration
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)
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
-
I have included changelog trailers, or none are needed. (Does this MR need a changelog?) -
I have added/updated documentation, or it's not needed. (Is documentation required?) -
I have properly separated EE content from FOSS, or this MR is FOSS only. (Where should EE code go?) -
I have added information for database reviewers in the MR description, or it's not needed. (Does this MR have database related changes?) -
I have self-reviewed this MR per code review guidelines. -
This MR does not harm performance, or I have asked a reviewer to help assess the performance impact. (Merge request performance guidelines) -
I have followed the style guides. -
This change is backwards compatible across updates, or this does not apply.
Availability and Testing
-
I have added/updated tests following the Testing Guide, or it's not needed. (Consider all test levels. See the Test Planning Process.) -
I have tested this MR in all supported browsers, or it's not needed. -
I have informed the Infrastructure department of a default or new setting change per definition of done, or it's not needed.