2019-07-08 04:50:38 -04:00
|
|
|
# Extra Sidekiq processes **(STARTER ONLY)**
|
2019-05-05 08:25:13 -04:00
|
|
|
|
2019-05-28 09:59:17 -04:00
|
|
|
NOTE: **Note:**
|
|
|
|
The information in this page applies only to Omnibus GitLab.
|
|
|
|
|
|
|
|
GitLab Starter allows one to start an extra set of Sidekiq processes
|
2019-05-05 08:25:13 -04:00
|
|
|
besides the default one. These processes can be used to consume a dedicated set
|
|
|
|
of queues. This can be used to ensure certain queues always have dedicated
|
|
|
|
workers, no matter the number of jobs that need to be processed.
|
|
|
|
|
2019-05-28 09:59:17 -04:00
|
|
|
## Available Sidekiq queues
|
2019-05-05 08:25:13 -04:00
|
|
|
|
2019-05-28 09:59:17 -04:00
|
|
|
For a list of the existing Sidekiq queues, check the following files:
|
2019-05-05 08:25:13 -04:00
|
|
|
|
2019-09-18 10:02:45 -04:00
|
|
|
- [Queues for both GitLab Community and Enterprise Editions](https://gitlab.com/gitlab-org/gitlab/blob/master/app/workers/all_queues.yml)
|
|
|
|
- [Queues for GitLab Enterprise Editions only](https://gitlab.com/gitlab-org/gitlab/blob/master/ee/app/workers/all_queues.yml)
|
2019-05-05 08:25:13 -04:00
|
|
|
|
2019-05-28 09:59:17 -04:00
|
|
|
Each entry in the above files represents a queue on which extra Sidekiq processes
|
|
|
|
can be started.
|
2019-05-05 08:25:13 -04:00
|
|
|
|
2019-05-28 09:59:17 -04:00
|
|
|
## Starting extra processes
|
2019-05-05 08:25:13 -04:00
|
|
|
|
2019-05-28 09:59:17 -04:00
|
|
|
To start extra Sidekiq processes, you must enable `sidekiq-cluster`:
|
2019-05-05 08:25:13 -04:00
|
|
|
|
2019-05-28 09:59:17 -04:00
|
|
|
1. Edit `/etc/gitlab/gitlab.rb` and add:
|
2019-05-05 08:25:13 -04:00
|
|
|
|
2019-05-28 09:59:17 -04:00
|
|
|
```ruby
|
|
|
|
sidekiq_cluster['enable'] = true
|
|
|
|
```
|
2019-05-05 08:25:13 -04:00
|
|
|
|
2019-05-28 09:59:17 -04:00
|
|
|
1. You will then need to specify how many additional processes to create via `sidekiq-cluster`
|
|
|
|
and which queue they should handle via the `sidekiq_cluster['queue_groups']`
|
|
|
|
array setting. Each item in the array equates to one additional Sidekiq
|
|
|
|
process, and values in each item determine the queues it works on.
|
2019-05-05 08:25:13 -04:00
|
|
|
|
2019-05-28 09:59:17 -04:00
|
|
|
For example, the following setting adds additional Sidekiq processes to two
|
|
|
|
queues, one to `elastic_indexer` and one to `mailers`:
|
2019-05-05 08:25:13 -04:00
|
|
|
|
2019-05-28 09:59:17 -04:00
|
|
|
```ruby
|
|
|
|
sidekiq_cluster['queue_groups'] = [
|
|
|
|
"elastic_indexer",
|
|
|
|
"mailers"
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
|
|
|
To have an additional Sidekiq process handle multiple queues, add multiple
|
|
|
|
queue names to its item delimited by commas. For example:
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
sidekiq_cluster['queue_groups'] = [
|
|
|
|
"elastic_indexer, elastic_commit_indexer",
|
|
|
|
"mailers"
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
|
|
|
1. Save the file and reconfigure GitLab for the changes to take effect:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
sudo gitlab-ctl reconfigure
|
|
|
|
```
|
|
|
|
|
|
|
|
Once the extra Sidekiq processes are added, you can visit the "Background Jobs"
|
2019-05-05 08:25:13 -04:00
|
|
|
section under the admin area in GitLab (`/admin/background_jobs`).
|
|
|
|
|
2019-05-28 09:59:17 -04:00
|
|
|
![Extra Sidekiq processes](img/sidekiq-cluster.png)
|
2019-05-05 08:25:13 -04:00
|
|
|
|
2019-05-28 09:59:17 -04:00
|
|
|
## Negating settings
|
2019-05-05 08:25:13 -04:00
|
|
|
|
2019-05-28 09:59:17 -04:00
|
|
|
To have the additional Sidekiq processes work on every queue **except** the ones
|
2019-05-05 08:25:13 -04:00
|
|
|
you list:
|
|
|
|
|
2019-05-28 09:59:17 -04:00
|
|
|
1. After you follow the steps for [starting extra processes](#starting-extra-processes),
|
|
|
|
edit `/etc/gitlab/gitlab.rb` and add:
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
sidekiq_cluster['negate'] = true
|
|
|
|
```
|
|
|
|
|
|
|
|
1. Save the file and reconfigure GitLab for the changes to take effect:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
sudo gitlab-ctl reconfigure
|
|
|
|
```
|
|
|
|
|
|
|
|
## Ignore all GitHub import queues
|
|
|
|
|
|
|
|
When [importing from GitHub](../../user/project/import/github.md), Sidekiq might
|
|
|
|
use all of its resources to perform those operations. To set up a separate
|
|
|
|
`sidekiq-cluster` process to ignore all GitHub import-related queues:
|
|
|
|
|
2019-05-05 08:25:13 -04:00
|
|
|
1. Edit `/etc/gitlab/gitlab.rb` and add:
|
|
|
|
|
|
|
|
```ruby
|
2019-05-28 09:59:17 -04:00
|
|
|
sidekiq_cluster['enable'] = true
|
2019-05-05 08:25:13 -04:00
|
|
|
sidekiq_cluster['negate'] = true
|
2019-05-28 09:59:17 -04:00
|
|
|
sidekiq_cluster['queue_groups'] = [
|
|
|
|
"github_import_advance_stage",
|
|
|
|
"github_importer:github_import_import_diff_note",
|
|
|
|
"github_importer:github_import_import_issue",
|
|
|
|
"github_importer:github_import_import_note",
|
|
|
|
"github_importer:github_import_import_lfs_object",
|
|
|
|
"github_importer:github_import_import_pull_request",
|
|
|
|
"github_importer:github_import_refresh_import_jid",
|
|
|
|
"github_importer:github_import_stage_finish_import",
|
|
|
|
"github_importer:github_import_stage_import_base_data",
|
|
|
|
"github_importer:github_import_stage_import_issues_and_diff_notes",
|
|
|
|
"github_importer:github_import_stage_import_notes",
|
|
|
|
"github_importer:github_import_stage_import_lfs_objects",
|
|
|
|
"github_importer:github_import_stage_import_pull_requests",
|
|
|
|
"github_importer:github_import_stage_import_repository"
|
|
|
|
]
|
2019-05-05 08:25:13 -04:00
|
|
|
```
|
|
|
|
|
2019-05-28 09:59:17 -04:00
|
|
|
1. Save the file and reconfigure GitLab for the changes to take effect:
|
2019-05-05 08:25:13 -04:00
|
|
|
|
2019-05-28 09:59:17 -04:00
|
|
|
```sh
|
|
|
|
sudo gitlab-ctl reconfigure
|
|
|
|
```
|
2019-05-05 08:25:13 -04:00
|
|
|
|
2019-05-28 09:59:17 -04:00
|
|
|
## Number of threads
|
|
|
|
|
|
|
|
Each process defined under `sidekiq_cluster` starts with a
|
|
|
|
number of threads that equals the number of queues, plus one spare thread.
|
|
|
|
For example, a process that handles the `process_commit` and `post_receive`
|
|
|
|
queues will use three threads in total.
|
|
|
|
|
|
|
|
## Limiting concurrency
|
|
|
|
|
2019-11-22 13:06:00 -05:00
|
|
|
To limit the concurrency of the Sidekiq process:
|
2019-05-05 08:25:13 -04:00
|
|
|
|
|
|
|
1. Edit `/etc/gitlab/gitlab.rb` and add:
|
|
|
|
|
|
|
|
```ruby
|
2019-11-22 13:06:00 -05:00
|
|
|
sidekiq['concurrency'] = 25
|
|
|
|
```
|
|
|
|
|
|
|
|
1. Save the file and reconfigure GitLab for the changes to take effect:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
sudo gitlab-ctl reconfigure
|
|
|
|
```
|
|
|
|
|
|
|
|
To limit the max concurrency of the Sidekiq cluster processes:
|
|
|
|
|
|
|
|
1. Edit `/etc/gitlab/gitlab.rb` and add:
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
sidekiq_cluster['max_concurrency'] = 25
|
2019-05-05 08:25:13 -04:00
|
|
|
```
|
|
|
|
|
2019-05-28 09:59:17 -04:00
|
|
|
1. Save the file and reconfigure GitLab for the changes to take effect:
|
2019-05-05 08:25:13 -04:00
|
|
|
|
2019-05-28 09:59:17 -04:00
|
|
|
```sh
|
|
|
|
sudo gitlab-ctl reconfigure
|
|
|
|
```
|
2019-05-05 08:25:13 -04:00
|
|
|
|
2019-05-28 09:59:17 -04:00
|
|
|
For each queue group, the concurrency factor will be set to `min(number of queues, N)`.
|
|
|
|
Setting the value to 0 will disable the limit. Keep in mind this normally would
|
|
|
|
not exceed the number of CPU cores available.
|
|
|
|
|
|
|
|
Each thread requires a Redis connection, so adding threads may
|
|
|
|
increase Redis latency and potentially cause client timeouts. See the [Sidekiq
|
|
|
|
documentation about Redis](https://github.com/mperham/sidekiq/wiki/Using-Redis)
|
|
|
|
for more details.
|
|
|
|
|
|
|
|
## Modifying the check interval
|
2019-05-05 08:25:13 -04:00
|
|
|
|
|
|
|
To modify the check interval for the additional Sidekiq processes:
|
|
|
|
|
|
|
|
1. Edit `/etc/gitlab/gitlab.rb` and add:
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
sidekiq_cluster['interval'] = 5
|
|
|
|
```
|
|
|
|
|
|
|
|
1. Save the file and [reconfigure GitLab](../restart_gitlab.md#omnibus-gitlab-reconfigure) for the changes to take effect.
|
|
|
|
|
|
|
|
This tells the additional processes how often to check for enqueued jobs.
|
|
|
|
|
2019-05-28 09:59:17 -04:00
|
|
|
## Troubleshooting using the CLI
|
2019-05-05 08:25:13 -04:00
|
|
|
|
2019-05-28 09:59:17 -04:00
|
|
|
CAUTION: **Warning:**
|
|
|
|
It's recommended to use `/etc/gitlab/gitlab.rb` to configure the Sidekiq processes.
|
|
|
|
If you experience a problem, you should contact GitLab support. Use the command
|
|
|
|
line at your own risk.
|
|
|
|
|
|
|
|
For debugging purposes, you can start extra Sidekiq processes by using the command
|
2019-05-05 20:56:13 -04:00
|
|
|
`/opt/gitlab/embedded/service/gitlab-rails/ee/bin/sidekiq-cluster`. This command
|
2019-05-05 08:25:13 -04:00
|
|
|
takes arguments using the following syntax:
|
|
|
|
|
|
|
|
```bash
|
2019-05-05 20:56:13 -04:00
|
|
|
/opt/gitlab/embedded/service/gitlab-rails/ee/bin/sidekiq-cluster [QUEUE,QUEUE,...] [QUEUE, ...]
|
2019-05-05 08:25:13 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
Each separate argument denotes a group of queues that have to be processed by a
|
|
|
|
Sidekiq process. Multiple queues can be processed by the same process by
|
|
|
|
separating them with a comma instead of a space.
|
|
|
|
|
|
|
|
Instead of a queue, a queue namespace can also be provided, to have the process
|
|
|
|
automatically listen on all queues in that namespace without needing to
|
|
|
|
explicitly list all the queue names. For more information about queue namespaces,
|
|
|
|
see the relevant section in the
|
|
|
|
[Sidekiq style guide](../../development/sidekiq_style_guide.md#queue-namespaces).
|
|
|
|
|
|
|
|
For example, say you want to start 2 extra processes: one to process the
|
2019-05-28 09:59:17 -04:00
|
|
|
`process_commit` queue, and one to process the `post_receive` queue. This can be
|
2019-05-05 08:25:13 -04:00
|
|
|
done as follows:
|
|
|
|
|
|
|
|
```bash
|
2019-05-05 20:56:13 -04:00
|
|
|
/opt/gitlab/embedded/service/gitlab-rails/ee/bin/sidekiq-cluster process_commit post_receive
|
2019-05-05 08:25:13 -04:00
|
|
|
```
|
|
|
|
|
2019-05-28 09:59:17 -04:00
|
|
|
If you instead want to start one process processing both queues, you'd use the
|
2019-05-05 08:25:13 -04:00
|
|
|
following syntax:
|
|
|
|
|
|
|
|
```bash
|
2019-05-05 20:56:13 -04:00
|
|
|
/opt/gitlab/embedded/service/gitlab-rails/ee/bin/sidekiq-cluster process_commit,post_receive
|
2019-05-05 08:25:13 -04:00
|
|
|
```
|
|
|
|
|
2019-05-28 09:59:17 -04:00
|
|
|
If you want to have one Sidekiq process dealing with the `process_commit` and
|
|
|
|
`post_receive` queues, and one process to process the `gitlab_shell` queue,
|
2019-05-05 08:25:13 -04:00
|
|
|
you'd use the following:
|
|
|
|
|
|
|
|
```bash
|
2019-05-05 20:56:13 -04:00
|
|
|
/opt/gitlab/embedded/service/gitlab-rails/ee/bin/sidekiq-cluster process_commit,post_receive gitlab_shell
|
2019-05-05 08:25:13 -04:00
|
|
|
```
|
|
|
|
|
2019-05-28 09:59:17 -04:00
|
|
|
### Monitoring the `sidekiq-cluster` command
|
2019-05-05 08:25:13 -04:00
|
|
|
|
|
|
|
The `sidekiq-cluster` command will not terminate once it has started the desired
|
|
|
|
amount of Sidekiq processes. Instead, the process will continue running and
|
|
|
|
forward any signals to the child processes. This makes it easy to stop all
|
|
|
|
Sidekiq processes as you simply send a signal to the `sidekiq-cluster` process,
|
|
|
|
instead of having to send it to the individual processes.
|
|
|
|
|
|
|
|
If the `sidekiq-cluster` process crashes or receives a `SIGKILL`, the child
|
|
|
|
processes will terminate themselves after a few seconds. This ensures you don't
|
|
|
|
end up with zombie Sidekiq processes.
|
|
|
|
|
|
|
|
All of this makes monitoring the processes fairly easy. Simply hook up
|
|
|
|
`sidekiq-cluster` to your supervisor of choice (e.g. runit) and you're good to
|
|
|
|
go.
|
|
|
|
|
|
|
|
If a child process died the `sidekiq-cluster` command will signal all remaining
|
|
|
|
process to terminate, then terminate itself. This removes the need for
|
|
|
|
`sidekiq-cluster` to re-implement complex process monitoring/restarting code.
|
|
|
|
Instead you should make sure your supervisor restarts the `sidekiq-cluster`
|
|
|
|
process whenever necessary.
|
|
|
|
|
|
|
|
### PID files
|
|
|
|
|
|
|
|
The `sidekiq-cluster` command can store its PID in a file. By default no PID
|
|
|
|
file is written, but this can be changed by passing the `--pidfile` option to
|
|
|
|
`sidekiq-cluster`. For example:
|
|
|
|
|
|
|
|
```bash
|
2019-05-05 20:56:13 -04:00
|
|
|
/opt/gitlab/embedded/service/gitlab-rails/ee/bin/sidekiq-cluster --pidfile /var/run/gitlab/sidekiq_cluster.pid process_commit
|
2019-05-05 08:25:13 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
Keep in mind that the PID file will contain the PID of the `sidekiq-cluster`
|
|
|
|
command and not the PID(s) of the started Sidekiq processes.
|
|
|
|
|
|
|
|
### Environment
|
|
|
|
|
|
|
|
The Rails environment can be set by passing the `--environment` flag to the
|
|
|
|
`sidekiq-cluster` command, or by setting `RAILS_ENV` to a non-empty value. The
|
2019-05-28 09:59:17 -04:00
|
|
|
default value can be found in `/opt/gitlab/etc/gitlab-rails/env/RAILS_ENV`.
|
2019-05-05 08:25:13 -04:00
|
|
|
|
2019-05-28 09:59:17 -04:00
|
|
|
### Using negation
|
2019-05-05 08:25:13 -04:00
|
|
|
|
|
|
|
You're able to run all queues in `sidekiq_queues.yml` file on a single or
|
|
|
|
multiple processes with exceptions using the `--negate` flag.
|
|
|
|
|
|
|
|
For example, say you want to run a single process for all queues,
|
2019-05-28 09:59:17 -04:00
|
|
|
except `process_commit` and `post_receive`:
|
2019-05-05 08:25:13 -04:00
|
|
|
|
|
|
|
```bash
|
2019-05-28 09:59:17 -04:00
|
|
|
/opt/gitlab/embedded/service/gitlab-rails/ee/bin/sidekiq-cluster process_commit,post_receive --negate
|
2019-05-05 08:25:13 -04:00
|
|
|
```
|
|
|
|
|
2019-05-28 09:59:17 -04:00
|
|
|
For multiple processes of all queues (except `process_commit` and `post_receive`):
|
2019-05-05 08:25:13 -04:00
|
|
|
|
|
|
|
```bash
|
2019-05-28 09:59:17 -04:00
|
|
|
/opt/gitlab/embedded/service/gitlab-rails/ee/bin/sidekiq-cluster process_commit,post_receive process_commit,post_receive --negate
|
2019-05-05 08:25:13 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
### Limiting concurrency
|
|
|
|
|
|
|
|
By default, `sidekiq-cluster` will spin up extra Sidekiq processes that use
|
|
|
|
one thread per queue up to a maximum of 50. If you wish to change the cap, use
|
|
|
|
the `-m N` option. For example, this would cap the maximum number of threads to 1:
|
|
|
|
|
|
|
|
```bash
|
2019-05-05 20:56:13 -04:00
|
|
|
/opt/gitlab/embedded/service/gitlab-rails/ee/bin/sidekiq-cluster process_commit,post_receive -m 1
|
2019-05-05 08:25:13 -04:00
|
|
|
```
|