Change event handlers to trigger queued jobs for dramatic performance boost #247
Closed
aaronbushnell
started this conversation in
Ideas
Replies: 3 comments 2 replies
-
Hey @aaronbushnell, Scout should run these in a queue job when you have the |
Beta Was this translation helpful? Give feedback.
2 replies
-
I submitted an initial pull request (#248) for this change. This definitely needs testing, but I believe it's a start to adding significant performance gains without needing to disable valuable features like |
Beta Was this translation helpful? Give feedback.
0 replies
-
Let's keep this going in #255 :) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Scout currently runs processes when elements qualify for the following events:
In a much earlier version, Scout would listen for these events and run index/deindex processes in a queued job. Over time, Scout migrated away for this strategy to the current implementation that runs these processes immediately.
Running these processes immediately is very slow if your site has many relationships and very large Algolia indices. That means you're often in a position where you often must set
indexRelations
tofalse
. While this can dramatically speed things up, it comes at a big cost of not propagating related element changes to indices using them.I'd really love to see Scout reconsider queued jobs when an element event is fired. This would greatly boost performance on elements events while still allowing
indexRelations
to be enabled.Handling
SAVE
,RESTORE
, andUPDATE
eventsI believe this job is the most straightforward to create. Moving the current steps into a job mostly involves:
id
(to avoidSerialization of 'Closure' is not allowed
errors)id
within the job->searchable()
functionCraft::$app->getQueue()->push()
to initialize the job in the current implementation.Handling
BEFORE_DELETE
andAFTER_DELETE
eventsThis is where things are more difficult and I don't have a solution off the top of my head. If you throw this work to a job you'll need to pass an
id
as a reference, but if the element is deleted, I don't believe you'll have a way to retrieve the element in the job and then process it.Would love to see this change because I think it would create a dramatically faster experience for any user of Scout!
Beta Was this translation helpful? Give feedback.
All reactions