Skip to content

Internal implementation: Running Tasks On One Server #41548

Answered by mikeydevelops
peco8 asked this question in Q&A
Discussion options

You must be logged in to vote

So by default Laravel asks you to configure cron job for php artisan schedule:run to be ran every minute.

  1. When you schedule an event/task with onOneServer it creates an Event instance and sets a public property $onOneServer to true.
  2. When the command is run, it collects all events/tasks that should run at that specific time.
  3. If it happens to run an event/task requiring to be run on only one server, it uses the default cache driver to create a so called mutex.
  4. A mutex is a unique lock (In computer science, a lock or mutex is a synchronization primitive: a mechanism that enforces limits on access to a resource when there are many threads of execution.)
  5. The mutex needs a name and each server g…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@khaledsbuyme
Comment options

@mikeydevelops
Comment options

@khaledsbuyme
Comment options

@mikeydevelops
Comment options

Answer selected by peco8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants