Serialize new-resource embedding fan-out - #3640
Open
feoh wants to merge 1 commit into
Open
Conversation
OpenAPI ChangesNo changes detected Unexpected changes? Ensure your branch is up-to-date with |
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request updates the vector_search scheduled embedding job to avoid a bursty Celery fan-out on the shared Redis broker by switching embed_new_learning_resources from a single celery.group(...) dispatch to the existing sequential _replace_with_chain(...) pattern used elsewhere in vector_search.
Changes:
- Replace
celery.group(tasks)+self.replace(...)inembed_new_learning_resourceswith_replace_with_chain(self, tasks)to serialize chunk dispatch. - Update the existing unit test to assert a
celery.chainis created (and no group is created) while preserving the embedded resource IDs. - Add a new unit test ensuring the no-work path returns
Noneand does not dispatch an empty canvas (no chain/group/replace calls).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| vector_search/tasks.py | Switch embed_new_learning_resources from group fan-out to sequential chain replacement to reduce broker queue-depth bursts. |
| vector_search/tasks_test.py | Update and expand tests to validate chain behavior and the no-work early-exit path. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What are the relevant tickets?
Related: #3623 and #3639
Description (What does it do?)
embed_new_learning_resourcesruns every 30 minutes and looks back across a wider window for newly created resources. It previously dispatched every Qdrant embedding chunk in that window as onecelery.group, immediately materializing the entire fan-out on the shared Redis broker. That creates a short-lived queue-depth burst, prompts KEDA to scale the embeddings worker fleet aggressively, and adds avoidable broker CPU pressure.This changes the task to use the existing
_replace_with_chainhelper, dispatching one embedding chunk at a time. The full-catalog and by-ID embedding entrypoints already use this pattern following #3484, where sequential chains were introduced specifically to prevent large embedding workloads from overwhelming Qdrant.The no-work path now completes directly instead of replacing the task with an empty group.
This is independent of #3639: that PR bounds OpenSearch reindex chords while preserving parallel batches and aggregate results; embedding chunks do not require chord result aggregation, so the existing sequential-chain mechanism is simpler and avoids chord bookkeeping entirely.
How can this be tested?
pytest vector_search/tasks_test.py(44 passed locally).For operational validation, observe the
embeddingsCelery queue during the next scheduled run: queue depth should no longer jump by the full number of lookback chunks at once, and KEDA should not scale the worker deployment solely for that fan-out burst.Additional Context
This deliberately trades parallelism for bounded pressure, matching the existing Qdrant protection strategy used by
start_embed_resources,embed_learning_resources_by_id, and content-file embedding tasks.