On 1/19/11 7:50 AM, Pierre Joye wrote: > Honestly if a given part of an application needs something along this > line for performance reasons, then doing that on the same box where > the request is executed may be a bad idea. Tools like gearman will do > a far better jobs and will let you do resource intensive processing on > other machines where cores may not be already busy serving other > requests. > > my 2 cents based on my experiences and benches in this area, In real-world situations this is what I see as well. People either want to parallelize operations like fetching data from multiple URLs at once, where they think they need threading, but actually just need to learn the async calls, or they want to background something that takes a while to finish. This second case is much better handled by a separate job manager like Gearman. One example I have written is a rule engine that calculates a trust score for a financial transaction. The rules can get a bit complicated so it isn't something I want to have the web request wait on. Using the Kohana framework the call to kick off the rule engine looks like this: Gearman::doBackground('kohana', "gearman/payment_score/{$payment->id}") And I have a 'kohana' gearman worker that loads the entire framework which means my actual worker code is just another controller that looks exactly like my Web code. Any controller can be backgrounded that way with the added advantage that I can distribute these backgrounded jobs to a pool of worker servers that are separate from my frontend web servers, but they all run the same code stack. To me this is a much more flexible way to solve the problem that having to write thread-management code in my Web code and have my already overloaded web servers take on more work. -Rasmus



