title: How to use AWS SQS with auto-scaling of spot instances EC2 workers and long running jobs?
body: <p>Let me explain...</p>
  
  <p>I have <strong>2 SQS queues</strong> that receive requests for execution of <strong>light</strong> and <strong>heavy</strong> report-generating jobs. 
  (The separation into two queues has been introduced for the light jobs not to be influenced by the heavy ones.)</p>
  
  <p>The SQS sends the jobs in an <strong>auto-scaling group that contains 3 workers</strong>.</p>
  
  <p>The workers are <strong>on-demand</strong> EC2 instances. I would like to change the launch configuration and use <strong>spot instances</strong>.</p>
  
  <p>The thing is that some report-generating heavy duty jobs may run for up to 4 hours. So if this kind of job runs on a spot instance worker that may be terminated , additional delays and/or complications will arise.</p>
  
  <p><em>I would like to use spot instances as workers but also to have the assurance that the worker will not be terminated if there is a job running on it.</em></p>
  
  <p>The approaches I came up with are the following:</p>
  
  <p><strong>1.</strong> Bid for the spot instances with the on-demand price of the instance [it still does not protect from termination but minimises the possibility]</p>
  
  <p><strong>2.</strong> Use spot instances with specific period [eg 6 hours] , but still I am confined to 6 hours and the instance terminates. Plus, I dont know if I can set this kind of setting from the launch configuration</p>