-
Notifications
You must be signed in to change notification settings - Fork 13
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
ws-worker: respond to a wake up call #869
Comments
I think this is a back door to a push (rather than pull) queue architecture. But that's fine. It's cheaper than re-engineering the whole thing, and means that Lightning can stay quite hands-off in terms of managing the worker pool. |
@stuartc before we start on this can I ask you to take a quick look at the spec above, make sure it all adds up? What do you think about the event name? |
Yeah everything adds up to me, how about As for a 'push' architecture, you're right - it's a nice step in that direction; but we're still avoiding having the cluster be aware of the state of all the workers. |
Tips for @doc-han:
If you want to use lightning with your local worker, start lightning with |
When each worker starts up, it joins a websocket channel with lightning (see
src/channels/worker-queue.ts
)It then polls that channel to "claim" any outstanding work items. Lighting will respond with 0 or more runs. If the worker receives no work, it'll back-off and poll a bit slower next time.
We want to add a feature where Lightning will send a "wake up" call to any workers with capacity. This allows us to short-cut the backoff and instantly claim any work, which lets is process runs faster.
So, the Worker needs to listen to some kind of event from lightning and, if it has capacity, instantly reset the backoff and trigger a fresh claim.
On the lightning side, this wake-up call needs to be sent similtaneously to everyone listening on the work queue. That could be a hundred workers. But it's Ok, because each worker will trigger a claim. The first one that happens to do so will get the work, and the others will be safely returned nothing.
We can engineer a response to this event on the worker side and test it with integration tests. Just set a super low backoff, trigger a wake up, and work should be instantly claimed. It's up to the Lightning team to work out how and when to send the wake up event.
Questions:
on-queue-added
?wake-up
?trigger-claim
?cancel-backoff
?The text was updated successfully, but these errors were encountered: