I have Laravel 5.0 running multiple web servers behind a load balancer. I use laravel Scheduler to execute and run commands on a regular basis. Most of these are not server-specific commands, but global (across the entire app across all servers).
The problem is that each server will execute each command - so 3 servers means 3 commands being run every hour/minute/whatever.
How would one synchronise execution of these commands between servers? Does Laravel have any native options? Any other packages to recommend?
An idea that occurred was to rely on the way Laravel implements its withoutOverlapping feature by using file-based mutex's, and use shared storage to distribute the files between servers. Might work, but any latency is the shared storage breaks this - not reliable enough.
My current workaround is to have the commands fire jobs onto the queue, and build the logic into the job handler itself to use the DB to synchronise itself between servers. Hardly elegant, but gets the job done.
This is related to Laravel Task Scheduler across multiple servers without overlap
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire