I used ruby's fork when I was sending 60,000 emails from one of Rails applications and it is wise to split the big result set and send emails of each chunk parallely on forks for faster processing! Here is a sample ruby code for processing N length data.
I tested it on Ubuntu 11, ruby 1.9.2, Rails 3.0.10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fork do | |
ActiveRecord::Base.establish_connection | |
for i in 0..20000 | |
puts 'I m in sub process-1' | |
end | |
exit | |
end | |
fork do | |
ActiveRecord::Base.establish_connection | |
for i in 2001..40000 | |
puts 'I m in sub process-2' | |
end | |
exit | |
end | |
....... | |
fork do | |
ActiveRecord::Base.establish_connection | |
for i in 40000..N | |
puts 'I m in sub process-M' | |
end | |
exit | |
end |