Brian Dailey wrote:
From the last link: "Note that you should never attempt to use these process control forking functions when using a webserver; you should only fork applications when using the PHP command line client."
   Another strategy is to write a long-running service task in a cron job.

For instance, imagine that you've got a web application that sends bulk e-mail, say groups in the 1000-10,000 people range.

It would be pretty crazy to have a single PHP script hanging there, running a foreach() loop to send 10,000 messages. All kinds of bad things can happen -- for instance, the sender thinks that the app is busted, reloads, reloads, and reloads again, so everybody ends up getting 4 messages.

A good answer in this case is to write a cron job/scheduled task that wakes up every five minutes, sends a few mails, and then dies. The background job is controlled by a work queue, which could be a table in the database. A system like this can send e-mail messages, gather information, or do computations in an orderly way -- it's easy to put in job controls of various sorts.
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

Reply via email to