Giter VIP home page Giter VIP logo

background-jobs-in-ror's Introduction

Background Jobs in ROR

Background jobs are used for executing tasks in which we don't need instant response. E.g Encoding video, generating sitemap, generating product listing feeds, image thumbnail generation etc

Rails provides lot of gems for background job processing but i am sharing these 2 according to my experience on moderate and huge traffic websites

1- Delayed_job

2- Sidekiq

Delayed_job:

This is oldest gem that i initially used in some of the projects and it worked quite well. But there are following pros & cons in comparison to Sidekiq.

Pros:

1- No extra tool required, by default uses main project db.

2- Suitable for project with few jobs on daily basis.

Cons:

1- By default use database as backend store and send lot of queries to main DB server in case of large no of jobs on daily basis.

2- No control panel for tracking jobs status and statistics

3- Don't take advantage of multi-threading.

Some useful commands:

RAILS_ENV=production script/delayed_job -n 2 start # n represent no of worker process you want to start to process jobs.

RAILS_ENV=production script/delayed_job stop

Sidekiq :

This is very good gem and i have used it in many projects. This gem has following pros & cons of gems in comparsion to delayed_job

Pros:

1- By default use Redis as backend store and you can offload lot of queries from your main db server in case of large no of jobs on daily basis. Redis is very fast as compared to RDBMS.

2- Good control panel for tracking job status, resubmit job, queue status and queue statistics etc.

3- Long list of third party add-on plugins to extend functionality according to needs.

4- Good utilization of CPU by using multi-threading

Cons:

1- Extra software(Redis) required.

Some interesting addons for getting more control on job execution flow:

1- Sidekiq Priority

2- Sidekiq Limit Fetch

3- Sidekiq Throttler

Some useful commands:

RAILS_ENV=production bundle exec sidekiq -c 10 -q critical,8 -q default # this job create 10 threads

Admin panel snapshot:

alt text

background-jobs-in-ror's People

Contributors

muhammadumarkhan-vf avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.