title: Resque: time-critical jobs that are executed sequentially per user
body: <p>My application creates resque jobs that must be processed sequentially per user, and they should be processed as fast as possible (1 second maximum delay).</p>
  
  <p>An example: job1 and job2 is created for user1 und job3 for user2. Resque can process job1 and job3 in parallel, but job1 and job2 should be processed sequentially. </p>
  
  <p>I have different thoughts for a solution:</p>
  
  <ul>
  <li>I could use different queues (e.g. queue_1 ... queue_10) and start a worker for each queue (e.g. <code>rake resque:work QUEUE=queue_1</code>). Users are assigned to a queue/ worker at runtime (e.g. on login, every day etc.)</li>
  <li>I could use dynamic "user queues" (e.g. queue_#{user.id}) and try to extend resque that only 1 worker can process a queue at a time (as asked in <a href="https://stackoverflow.com/questions/9266415/resque-one-worker-per-queue">Resque: one worker per queue</a>)</li>
  <li>I could put the jobs in a non-resque queue and use a "per-user meta job" with resque-lock (<a href="https://github.com/defunkt/resque-lock" rel="nofollow noreferrer">https://github.com/defunkt/resque-lock</a>) that handles those jobs.</li>
  </ul>
  
  <p>Do you have any experiences with one of those scenarios in practice? Or do have other other ideas that might be worth thinking about? I would appreciate any input, thank you!</p>