i852 Improve slow video processing speeds #955
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Story
Refs
@orangewolf and I determined that the slowness identified in #852 is due to insufficient CPU resources;
ffmpeg
commands run on large files were being throttled and thus running extremely slowly.To solve this, we decided that when an audio or video derivative job is triggered, we should put in into a separate Sidekiq queue (i.e.
:resource_intensive
). We'll have the default worker(s) run all queues other than:resource_intensive
. We'll also have a new, separate worker that runs all the other queues plus the:resource_intensive
queue. The new worker will have 4x the CPU resources that the default workers have, but only 1 thread.This effectively creates a powerful "slow lane".
:resource_intensive
jobs will slow down the separate worker while they're running, but they won't bog down all the jobs since the other workers are still running.Part 1
This PR implements the first part of the solution described above. Specifically, it:
:resource_intensive
Sidekiq queue:resource_intensive
queueExpected Behavior Before Changes
Video and audio files get processed by the
CreateDerivativesJob
in the:default
Sidekiq queueExpected Behavior After Changes
Video and audio files get processed by the
CreateLargeDerivativesJob
in the:resource_intensive
Sidekiq queueScreenshots / Video
Notes
Flow of logic introduced in this PR