[nycphp-talk] [OT] MySQL Queue
csnyder
chsnyder at gmail.com
Tue Apr 17 10:38:21 EDT 2007
On 4/17/07, Ben Sgro (ProjectSkyline) <ben at projectskyline.com> wrote:
> 1) Every x min, select the oldest time from the queue (LIMIT 1)
> 2) DELETE that row from the queue
> 3) Execute the job
Simple improvement would be to mark the job as "active" along with the
pid of the process that is working on it, rather than deleting the
record. That way if something goes wrong, you don't have to reinsert.
Also, you can tell how many active jobs you have and decline to start
new ones past a certain threshold.
Think about what information you need for error recovery, too. After
all, you probably only want to retry a "problem" job a certain number
of times before giving up, notifying an admin, etc.
--
Chris Snyder
http://chxo.com/
More information about the talk
mailing list