title: Laravel cron/queue/workers setup on multiple servers
body: <p>I've got multiple servers sharing a database - on each of them a cron job fires ever 5 min checking if a text message log entry doesn't exist, creates a text message log entry and sends out a text message. I thought that there would never be a situation where text messages are sent multiple times, as one server should be first.</p>
  
  <p>Well - I was wrong and that scenario did happen:</p>
  
  <ul>
  <li>A - check if log exists - it doesn't</li>
  <li>B - check if log exists - it doesn't</li>
  <li>A - create log</li>
  <li>B - create log</li>
  <li>A - send message</li>
  <li>B - send message</li>
  </ul>
  
  <p>I've changed this behaviour to introduce queue, which should mitigate the issue. While the crons will still fire, multiple jobs will be queued, and workers should pick up given jobs at different times, thus preventing of sending of message twice. Though it might as well end up being:</p>
  
  <ul>
  <li>A - pick up job 1</li>
  <li>B - pick up job 2</li>
  <li>A - check if log exists - it doesn't</li>
  <li>B - check if log exists - it doesn't</li>
  </ul>
  
  <p>Etc or A and B might as well pickup the same job at exactly the same time.</p>
  
  <p>The solution would be, I guess, to run one worker server. But then I've the situation that jobs from multiple servers are queued many times, and I can't check if they're already enqueued as we end up with first scenario.</p>
  
  <p>I'm at loss on how to proceed here - while multiple server, one worker server setup will work, I don't want to end up with instances of the same job (coming from different servers) multiple times in the queue.</p>
  
  <p>Maybe the solution to go for is to have one cron/queue/worker server, but I don't have experience with Laravel/multiserver environment to set it up.</p>
  
  <p>The other problematic thing for me is - how to test this? I can't, I guess, test it locally unless there's a way I can spin VM instances that are synchronized with each other.</p>