HighDots Forums  

Simultaneous long-running tasks; Rake, Daemons,

Ruby On Rails Talk Ruby On Rails programming language mailing list


Discuss Simultaneous long-running tasks; Rake, Daemons, in the Ruby On Rails Talk forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Sebastian von Conrad
 
Posts: n/a

Default Simultaneous long-running tasks; Rake, Daemons, - 11-03-2009 , 08:52 PM






Hi everyone,

I have an application where an essential part is communicating with a
remote API via SOAP. I want to be able to run 3-4 of these tasks at
once, and one task might take anything from one minute to several
hours, depending on the size of the data being sent. The app relies
heavily on ActiveRecord fetching fetching data (in_batches) and
updating it once the response from the API has been received.

I'm using Ruby 1.8.6 and Rails 2.3.4.

In an earlier version of this application (written in PHP), this was
set up as a cron job which called the relevant scripts via curl. This
was obviously not the best implementation, and so it was decided to
move to Rails.

After having done quite a bit of research, I can't for the life of me
figure out what the best approach to handle these long-running tasks
would be. Initially I was going to set them up as Rake tasks, and call
them with cron every minute. I had a database table with active tasks
and would only start the task if less than 4 tasks were already
running.

Then I discovered Daemons, and was trying to figure out if that would
be a better approach to my issue. And then, I discovered
Delayed::Jobs, which also could be helpful.

Naturally, I want to perform these tasks as efficiently as possible,
with the least amount of resources. The tasks will be more-or-less
around the clock, so I would probably rather have it run continually
(like a Daemon) than having to reload the libraries every time (which
I would have to do with Rake). On the other hand, I'm not sure how a
Daemon would handle concurrent tasks--threading, possibly?

With all of the different options out there, I'm getting more and more
confused by the minute. Help, anyone?

Best regards,
Sebastian
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk (AT) googlegroups (DOT) com
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe (AT) googlegroups (DOT) com
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply With Quote
  #2  
Old   
E. Litwin
 
Posts: n/a

Default Re: Simultaneous long-running tasks; Rake, Daemons, - 11-04-2009 , 11:41 AM






I'm using delayed_job and am happy with the ease of use.
I haven't had the need to run more than 1 queued job at a time, but
you can start any number of workers using the following syntax:

# This would allow up to four simultaneous jobs
$ RAILS_ENV=production script/delayed_job -n 4 start


On Nov 3, 5:52*pm, Sebastian von Conrad
<sebastian.von.con... (AT) gmail (DOT) com> wrote:
Quote:
Hi everyone,

I have an application where an essential part is communicating with a
remote API via SOAP. I want to be able to run 3-4 of these tasks at
once, and one task might take anything from one minute to several
hours, depending on the size of the data being sent. The app relies
heavily on ActiveRecord fetching fetching data (in_batches) and
updating it once the response from the API has been received.

I'm using Ruby 1.8.6 and Rails 2.3.4.

In an earlier version of this application (written in PHP), this was
set up as a cron job which called the relevant scripts via curl. This
was obviously not the best implementation, and so it was decided to
move to Rails.

After having done quite a bit of research, I can't for the life of me
figure out what the best approach to handle these long-running tasks
would be. Initially I was going to set them up as Rake tasks, and call
them with cron every minute. I had a database table with active tasks
and would only start the task if less than 4 tasks were already
running.

Then I discovered Daemons, and was trying to figure out if that would
be a better approach to my issue. And then, I discovered
Delayed::Jobs, which also could be helpful.

Naturally, I want to perform these tasks as efficiently as possible,
with the least amount of resources. The tasks will be more-or-less
around the clock, so I would probably rather have it run continually
(like a Daemon) than having to reload the libraries every time (which
I would have to do with Rake). On the other hand, I'm not sure how a
Daemon would handle concurrent tasks--threading, possibly?

With all of the different options out there, I'm getting more and more
confused by the minute. Help, anyone?

Best regards,
Sebastian
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk (AT) googlegroups (DOT) com
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe (AT) googlegroups (DOT) com
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply With Quote
  #3  
Old   
Sebastian von Conrad
 
Posts: n/a

Default Re: Simultaneous long-running tasks; Rake, Daemons, - 11-04-2009 , 07:16 PM



Thank you for your reply.

I do like the look of Delayed::Job, and after seeing your reply I
discovered that I must have glossed over something important: That you
can set up multiple workers on one computer.

I also noticed that you can use Delayed::Job together with a Daemon:
http://wiki.github.com/tobi/delayed_job/running-delayedworker-as-a-daemon

Does anyone have experience with this setup? If so, how is it working
for you?

Best regards,
Sebastian

On Nov 5, 2:41*am, "E. Litwin" <elit... (AT) rocketmail (DOT) com> wrote:
Quote:
I'm using delayed_job and am happy with the ease of use.
I haven't had the need to run more than 1 queued job at a time, but
you can start any number of workers using the following syntax:

# This would allow up to four simultaneous jobs
$ RAILS_ENV=production script/delayed_job -n 4 start

On Nov 3, 5:52*pm, Sebastian von Conrad

sebastian.von.con... (AT) gmail (DOT) com> wrote:
Hi everyone,

I have an application where an essential part is communicating with a
remote API via SOAP. I want to be able to run 3-4 of these tasks at
once, and one task might take anything from one minute to several
hours, depending on the size of the data being sent. The app relies
heavily on ActiveRecord fetching fetching data (in_batches) and
updating it once the response from the API has been received.

I'm using Ruby 1.8.6 and Rails 2.3.4.

In an earlier version of this application (written in PHP), this was
set up as a cron job which called the relevant scripts via curl. This
was obviously not the best implementation, and so it was decided to
move to Rails.

After having done quite a bit of research, I can't for the life of me
figure out what the best approach to handle these long-running tasks
would be. Initially I was going to set them up as Rake tasks, and call
them with cron every minute. I had a database table with active tasks
and would only start the task if less than 4 tasks were already
running.

Then I discovered Daemons, and was trying to figure out if that would
be a better approach to my issue. And then, I discovered
Delayed::Jobs, which also could be helpful.

Naturally, I want to perform these tasks as efficiently as possible,
with the least amount of resources. The tasks will be more-or-less
around the clock, so I would probably rather have it run continually
(like a Daemon) than having to reload the libraries every time (which
I would have to do with Rake). On the other hand, I'm not sure how a
Daemon would handle concurrent tasks--threading, possibly?

With all of the different options out there, I'm getting more and more
confused by the minute. Help, anyone?

Best regards,
Sebastian
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk (AT) googlegroups (DOT) com
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe (AT) googlegroups (DOT) com
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.