Server optimizations#972
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR focuses on reducing Redis cache pressure and tightening concurrency around preview/thumbnail generation, while making thumbnail sizing configurable via server config.
Changes:
- Reduced Redis-cached thumbnail TTL from 2 hours to 10 minutes.
- Introduced
ayonconfig.thumbnail_sizeand routed thumbnail resizing through config instead of hardcoded constants. - Added a global semaphore around
ffmpegthumbnail extraction and coalesced concurrent preview requests.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| cli/optimize_thumbnails/optimize_thumbnails.py | Uses configured thumbnail size when optimizing thumbnails. |
| ayon_server/lib/redis.py | Makes Redis.keys() resilient to both bytes and str key types. |
| ayon_server/helpers/thumbnails/store_thumbnail.py | Uses configured thumbnail size when storing thumbnails. |
| ayon_server/helpers/thumbnails/process_thumbnail.py | Removes hardcoded thumbnail size constants (now config-driven elsewhere). |
| ayon_server/helpers/thumbnails/common.py | Reduces Redis TTL for thumbnail retrieval caching and adjusts response headers order. |
| ayon_server/helpers/preview.py | Adds semaphore for ffmpeg work and request coalescing for file previews. |
| ayon_server/config/ayonconfig.py | Adds thumbnail_size configuration option. |
| ayon_server/auth/session.py | Refactors session TTL/expiry logic into SessionModel properties. |
| api/files/files.py | Updates still-frame extraction call site for new create_video_thumbnail signature. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
This pull request introduces several improvements and refactors related to thumbnail generation and session management. The main focus is on centralizing the thumbnail size configuration, improving concurrency and error handling in video thumbnail creation, and cleaning up session expiration logic. Below are the most important changes grouped by theme:
thumbnail_sizeinayonconfig, replacing hardcoded max width/height values across the codebase for thumbnail and preview generation. All relevant logic now usesayonconfig.thumbnail_sizefor consistency.create_video_thumbnailto accept athumbnailflag and use the centralized thumbnail size. Also improved ffmpeg command construction and logging for better traceability and debugging.Caching and Performance
RequestCoalescerfor file preview requests to deduplicate concurrent requests for the same resource, reducing redundant processing.Session Management Refactor
SessionModelproperties (ttl,is_expired), simplifying code and improving maintainability.Other Improvements
keysmethod.These changes collectively improve configurability, maintainability, and reliability of thumbnail and session handling in the application.