title: Scheduled job in a multi node environment
body: <p>I am working on a scheduled job that will run at certain interval (eg. once a day at 1pm), scheduled through Cron. I am working with Java and Spring.</p>
  
  <p>Writing the scheduled job is easy enough - it does: grab list of people will certain criteria from db, for each person do some calculation and trigger a message.</p>
  
  <p>I am working on a single-node environment locally and in testing, however when we go to production, it will be multi-node environment (with load balancer, etc). My concern is how would multi node environment affect the scheduled job?</p>
  
  <p>My guess is I could (or very likely would) end up with triggering duplicate message.</p>
  
  <ul>
  <li>Machine 1: Grab list of people, do calculation</li>
  <li>Machine 2: Grab list of people, do calculation</li>
  <li>Machine 1: Trigger message</li>
  <li>Machine 2: Trigger message</li>
  </ul>
  
  <p>Is my guess correct?</p>
  
  <p>What would be the recommended solution to avoid the above issue? Do I need to create a master/slave distributed system solution to manage multi node environment?</p>