- Views: 16
- Report Article
- Articles
- Computers
- Programming
Resque Gem : For Background Processes In ROR
Posted: Nov 25, 2015
Elegant and fun? These phrases are not something you would associate with a programming language. Right? But this is exactly what Ruby on Rails is. Ruby on Rails, more commonly called as just Rails, is a pure object-oriented programming language with simple and user-friendly clean syntax. And by meaning simple and user-friendly, it means that you can get a web application ready much sooner than with any other programming language. To go live, all you need is web server and database. And of course, some gems! One of the best part about Ruby is the huge list of categorized, reusable codes suitably termed as "gems". The beauty of Ruby on Rails lies in the fact that with the help of these gems, you can create applications easily and with considerably less efforts as compared to other technologies. Read on to know about Rasque which is a gem to create background jobs.
Resque creates background jobs using Redis. Since it supports multiple queue, we can place them on multiple queues and process them later as well. And it comes with an administration interface for monitoring and managing the queues.
Resque is intended to be used in situations where high volume of job entries are required, and provides mechanisms to ensure reflectiveness and consistency of behaviour while providing statistics using a web dashboard.
When we have a long processing block of code which we don’t need to execute it inside our web application request cycle, a background processing queuing system is the only good solution. Hence we get faster performing ruby application.
Though Resque is inspired by DelayedJob to a great extent, if we need multiple queues in our APP, Resque is probably a better choice.
Choose Resque If:
- You require multiple queues
- You don’t particularly fancy numeric priorities
- You work with huge queues
- You work with Redis
- You’re not going to run short on RAM
Since there are a number of open source queuing systems available (delayed_job, beanstalk) we don’t need to write our own!
Here, it will go over how to setup the resque queuing system in a Ruby on Rails application.
Resque Setup:
bash:
brew install redis
redis-server /usr/local/etc/redis.conf
resque-web
rake resque:work QUEUE=’*’
Gemfile:
gem ‘resque’, :require => "resque/server"
Install the new gem:
bundle install
Create a redis config file called redis.yml in config:
defaults: &defaults
host: localhost
port: 3002
development:
Visit our site to know more.
Rank Technologies is a leading IT solutions provider based in Bangalore, India. Recognised amongst the leading Ruby on Rails Development Companies in India, Rank caters to clients of varied sizes representing a variety of industries and operating from countries around the globe. Our passion for thought-provoking and stimulating innovation ensures that your project exudes ‘value’ at all times. We combine deep technology expertise and industry-specific insights into how technology impacts people and processes to deliver ruby on rails solutions that help clients achieve business outcomes with agility, speed and certainty.