Salil
Salil

Reputation: 47482

Rails Creating new thread or Background process

I have an issue of Time out error when i click on the Export to Excel link in my application, due to heavy db transactions. I want to change this functionality to the background so that user able to move forward while background process runs. I want when user clicks on Export to Excel link background/new thread process runs and an email is sent to the user with a link to download a file. I want to know which is best way to achieve this Creating new thread or Background process?

Thanks in Advance

Upvotes: 5

Views: 2075

Answers (2)

nkm
nkm

Reputation: 5914

There are three types of messages queues,

  1. No queues - a new thread / process will be triggered for background task, eg: spawn
  2. Database driven - corresponding task will be stored in a table in the database and will be deleted automatically on completion, eg: backgroundrb, delayed job
  3. Message queues - Stored jobs in memory, eg: starling

I haven't used resque, but heard that it is bit complicated to configure. Apart from running tasks in background, if you want to run some repetitive task on regular intervals, you can go for backgroundrb. Otherwise delayed job will be right choice.

Upvotes: 0

Related Questions