Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Also you can benefit from being able to use all of SQL to manage the queue.

I built a system ages ago that had modest queue needs.. maybe 100 jobs a day. It involved syncing changes in the local database with external devices. Many changes would ultimately update the same device, and making the fewest number of updates was important.

The system used an extremely simple schema: A table with something like [job_id, device, start_after, time_started, time_finished]

When queueing a job for $device, do an upsert to either insert a new record, or bump up the start_after of a not yet started job to now+5 minutes. When looking for a job to run, ignore anything with a start_after in the future.

As edits were made, it would create a single job for each device that would run 5 minutes after the last change was made.

I know a lot of queueing systems have the concept of a delayed job, but I haven't come across any that had the concept of delayed jobs+dedup/coalescence.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: