September 2006 :: Working with Queues

Today we talked all about Queues. Not just the shift/unshift kind of queues, but the good stuff – those database-driven, keeps everything from happening at once kind of queues.

You can find the presentation in both SWF and ODF (OOO Impress) formats.

Feel free to start a discussion! What other Queues have you built? What else could you use this concept for? Any thing that you know of that makes working with Queues even easier? Don’t be shy, feel free to add a comment!

  • http://kcpug.org Daniel Holmes
    Re: September 2006 :: Working with Queues
    Something we talked about:

    If you are going to have a queue that is being read by more than one process at the same time, it is essential that your database supports row level locking. You can get away with table-level locking, but you might start getting into a delay as you add more processes.

    So, for example, a background process looking to do work would:

    Check for work to do
      If work found, Lock the record
        If it locked, update the record that it is being worked on
        Remove lock
        Do work
        Update the status
    

    This way, if you had 3 servers with 2 of these processes on each, you would not have to worry about duplication of work.

    Enjoy the Show!