How to use Workling in Rails to increase the speed of the request processing

Renu's Blog

In ruby on rails application, if your request is taking too much time to process, you can make some part of the code to run in background.

For example,

In my application , I am sending notifications to owner,watch listers and trackers of a post, if there is any activity on the post. So when someone comments on the post, people will be getting notifications. I am using delayed jobs to generate notifications. But the problem here is inserts into delayed jobs. Whenever I comment on a post, all the inserts into the delayed job table takes long time, hence the response is coming too late.

My CommentsController

class CommentsController < ApplicationController

  def comment
   @comment = Comment.new(params[:comment])
   @comment.save
   @comment.send_messages
  end
end

To make the inserts into delayed jobs in the background, I used Workling. Implementing Workling is very simple.

1. Install the Workling plugin

script/plugin install git://github.com/purzelrakete/workling.git

2. Create theā€¦

View original post 55 more words

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s