asdlfkjlkj
asdlfkjlkj

Reputation: 2348

Delayed job: when and how to use

I have few queries regarding delayed job. I have configured this two gems in the development right now. But im not sure whether I need to use them or even if I use it how should I use it in server.

gem 'delayed_job_active_record'
gem 'daemons', '~> 1.2', '>= 1.2.3'
  1. I have a simple application which send emails to around 300-400 customers twice in a year. Is it necessary to use delayed job gem for such small number of emails? Our server is not busy at those two times of the year at all.

  2. If I use the delayed job I have to start the daemon first. In development I do it like this bundle exec rake jobs:work. Since this process will be always running in the server. Does this cause performance issue? Do I have to use another server or something just to run the delay job process?

  3. Lastly, how to run the command in production bundle exec rake jobs:work. Currently, I open a terminal and run the command. But I think if I close the terminal the process also stops. So how should I start it to keep it running at the background?

Upvotes: 0

Views: 758

Answers (1)

Bruno The Frank
Bruno The Frank

Reputation: 384

1st - I think that is a good practice to use DJ for all async jobs, imagine that we can face a down or anyother error with the e-mail server and your client would not receive this e-mail, with DJ, in case of error it will retry the job later.

2nd - I think that you don't need an entire server to run DJ, unless you have heavy jobs with long processing times or a large number of jobs per minute, in the prior case described, only a little more memory is enough for solving the problem.

3rd - An upstart script is the right way to do this, the S.O will handle this and will restart the service if it get down, the gem Foreman can help you with this.

Upstart example: https://larry-price.com/blog/2013/08/31/using-foreman-to-create-an-upstart-service

See ya!

Upvotes: 1

Related Questions