title: Asynchronous processing or message queues in PHP (CakePHP)
body: <p>I am building a website in CakePHP that processes files uploaded though an XML-RPC API and though a web frontend. Files need to be scanned by ClamAV, thumbnails need to be generated, et cetera. All resource intensive work that takes some time for which the user should not have to wait. So, I am looking into asynchronous processing with PHP in general and CakePHP in particular.</p>
  
  <p>I came across the <a href="http://blogs.bigfish.tv/adam/2009/02/16/new-cakephp-multitask-plugin/" rel="noreferrer">MultiTask plugin</a> for CakePHP that looks promising. I also came across various message queue implementations such as <a href="https://www.dropr.org/" rel="noreferrer">dropr</a> and <a href="http://xph.us/software/beanstalkd/" rel="noreferrer">beanstalkd</a>. Of course, I will also need some kind of background process, probably implemented using a Cake Shell of some kind. I saw MultiTask using <a href="http://pear.php.net/package/PHP_Fork/docs" rel="noreferrer">PHP_Fork</a> to implement a multithreaded PHP daemon.</p>
  
  <p>I need some advice on how to fit all these pieces together in the best way.</p>
  
  <ul>
  <li>Is it a good idea to have a long-running daemon written in PHP? What should I watch out for?</li>
  <li>What are the advantage of external message queue implementations? The MultiTask plugin does not use an external message queue. It rolls it's own using a MySQL table to store tasks.</li>
  <li>What message queue should I use? dropr? beanstalkd? Something else?</li>
  <li>How should I implement the backend processor? Is a forking PHP daemon a good idea or just asking for trouble?</li>
  </ul>
  
  <p>My current plan is either to use the MultiTask plugin or to edit it to use beanstald instead of it's own MySQL table implementation. Jobs in the queue can simply consist of a task name and an array of parameters. The PHP daemon would watch for incoming jobs and pass them out to one of it's child threads. The would simply execute the CakePHP Task with the given parameters.</p>
  
  <p>Any opinion, advice, comments, gotchas or flames on this?</p>