title: Processing items in SQS queue with a php script
body: <p>Here's my situation:</p>
  
  <p>I have a script that gets raw data, saves it in the database, get the item id then posts it to an amazon SQS queue.</p>
  
  <p>I have another script (written in PHP) that retrieves the raw data from the db and processes it. (it takes a couple of minutes usually.</p>
  
  <p>The missing part is how to retrieve the messages from SQS to be processed. The frequency of new data to process varies, it can go from a few items per hours to dozens of items per minute.</p>
  
  <p>One way would be to have a cron job that queries SQS for new messages and launch the processing script (It would have to be multi-threaded and written in something other than php. Python or Ruby perhaps). The problem wit the cron is that it is pretty inefficient, in high load phases it would be overwhelmed and in quiet phases it would be doing useless calls.</p>
  
  <p>What I would like to have is some kind of multi-threaded listener that would receive messages and process them. One important requirement is to have the raw data processed in a timely manner, a couple of minutes after being received at most.</p>
  
  <p>Any thoughts on the best solution? Is SQS appropriate for the task? What's the most efficient way to listen and process the queue?</p>