Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the option to use Symfony locks #1604

Open
BentiGorlich opened this issue Aug 14, 2024 · 3 comments
Open

Add the option to use Symfony locks #1604

BentiGorlich opened this issue Aug 14, 2024 · 3 comments

Comments

@BentiGorlich
Copy link

Is your feature request related to a problem? Please describe.
When a user uploads a pretty large image that takes some time to generate a thumbnail for and said user keeps on hitting f5 on the page because the image is not loading (it is being generated) multiple processes try to generate the thumbnail, one for each reload. Because the image processing on its own can eat up RAM quite well you can run into the issue that you php-fpm process gets killed to recover memory, because otherwise the server would crash

Describe the solution you'd like
Add the option to use the Symfony lock component so each image can only be processed by exactly one process at a time

Describe alternatives you've considered
I though about triggering the generation on uploading the image and that might help, but it doesn't really solve the issue

Additional context
https://github.com/MbinOrg/mbin

@TheVillageGuy
Copy link

TheVillageGuy commented Aug 14, 2024

Adding to this; because the new image is federated other users come in to look at the image as well within a matter of seconds (some servers don't make their own ocal copies but link directly to the new image) so there can easily be 10 users requesting and even F5ing the same image, pushing the server to its memory limit

@dbu dbu added this to the 3.0 Refactoring milestone Sep 1, 2024
@dbu
Copy link
Member

dbu commented Sep 1, 2024

there is integration with symfony messenger to pre-render images when they are uploaded. but of course that is asynchronous and therefore won't prevent your user from refreshing. we should be using (not sure how well we currently do) the symfony event system so that you could setup messenger to warmup and notify other people only when the cache warmup is done instead of immediately, if your project is all about images.

but nonetheless, using the lock component to prevent parallel warmups seems like a good idea. we are currently ™️ in the process of thinking up version 3 of this bundle, and aim to radically refactor everything to have clean and clear interfaces and workflows.

i added this issue to the 3.0 refactoring milestone so we keep this in mind too. if you want to get involved in the refactoring, the starting point would be #1590

@BentiGorlich
Copy link
Author

Oh that sounds great. Maybe if the warmup messages would be sent to the sync transport it could actually be done on uploading...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants