Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8043203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:49:50+00:00 2026-06-05T04:49:50+00:00

My application creates resque jobs that must be processed sequentially per user, and they

  • 0

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).

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.

I have different thoughts for a solution:

  • I could use different queues (e.g. queue_1 … queue_10) and start a worker for each queue (e.g. rake resque:work QUEUE=queue_1). Users are assigned to a queue/ worker at runtime (e.g. on login, every day etc.)
  • 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 Resque: one worker per queue)
  • I could put the jobs in a non-resque queue and use a “per-user meta job” with resque-lock (https://github.com/defunkt/resque-lock) that handles those jobs.

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T04:49:51+00:00Added an answer on June 5, 2026 at 4:49 am

    Thanks to the answer of @Isotope I finally came to a solution that seems to work (using resque-retry and locks in redis:

    class MyJob
      extend Resque::Plugins::Retry
    
      # directly enqueue job when lock occurred
      @retry_delay = 0 
      # we don't need the limit because sometimes the lock should be cleared
      @retry_limit = 10000 
      # just catch lock timeouts
      @retry_exceptions = [Redis::Lock::LockTimeout]
    
      def self.perform(user_id, ...)
        # Lock the job for given user. 
        # If there is already another job for the user in progress, 
        # Redis::Lock::LockTimeout is raised and the job is requeued.
        Redis::Lock.new("my_job.user##{user_id}", 
          :expiration => 1, 
          # We don't want to wait for the lock, just requeue the job as fast as possible
          :timeout => 0.1
        ).lock do
          # do your stuff here ...
        end
      end
    end
    

    I am using here Redis::Lock from https://github.com/nateware/redis-objects (it encapsulates the pattern from http://redis.io/commands/setex).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i just got a call from Hosting company, they claimed that my application creates
I have an application that creates a log file on external device and passes
So i have an application that creates like 2000 objects. For each object, it
My application creates a text file. I want that users to have easy access
My application creates a shortcut on the user's desktop with a standard icon. How
My application creates a thread and that runs in the background all the time.
My application creates a helper pthread that I need to have run at a
My application creates pieces of data that, in xml, would look like this: <resource
I have an application that has a class named: UploadItem. The application creates uploading
My application creates coupons that each need a unique barcode number. This number needs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.