codeclimate/sqskiq

Name: sqskiq

Owner: Code Climate

Description: Efficient Ruby background processing using Amazon SQS

Forked from: ricardolazaro/sqskiq

Created: 2017-01-26 21:32:33.0

Updated: 2017-01-26 21:32:35.0

Pushed: 2017-01-26 22:44:48.0

Homepage:

Size: 75

Language: Ruby

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Build Status

Sqskiq

High performance, Sidekiq-like Amazon SQS messages consumer. Currently only supports Rails 3.x.

SQS is complete message solution powered by Amazon, including monitoring, alarms, redundancy, etc. Due to its particularities, we decided to build a message consumer from scratch, to better handle costs, latency and others.

Getting Start
  1. Add sqskiq to your Gemfile:

    'sqskiq'
    
  2. Add an initializer config/initializers/sqskiq.rb with:

    iq.configure do |c|
    configuration = {
    aws_access_key_id: 'AWS_ACCESS_KEY_ID'
    aws_secret_access_key: 'AWS_SECRET_ACCESS_KEY'
    
    
    
  3. Add a worker in app/workers to process messages asynchronously:

    s HardWorker
    clude Sqskiq::Worker
    
    skiq_options queue_name: :queue_test
    
    f perform(message)
    # do something
    d
    
    

    The message received by this worker is an instance of AWS::SQS::ReceivedMessage

    Configure the parallelism using the param processors: sqskiq_options queue_name: :queue_test, processors: 30 Currently, the min number of processors is 2 and the default is 20. Any unacceptable value will end up using the default.

    Configure how long sqskiq will delay new fetches using the param empty_queue_throttle in seconds: sqskiq_options queue_name: :queue_test, empty_queue_throttle: 20 #for 20 seconds of delay If the queue got empty, sqskiq will wait empty_queue_throttle seconds to perform a new fetch. This can drastically reduce your sqs costs.

  4. Start Sqskiq and consume the queue:

    s runner HardWorker.run
    
  5. Publish message

    Worker.perform_async(params)
    
Deploy

Use a Procfile (like Heroku does) to start your workers. In your Procfile, add:

eue_test: rails runner 'HardWorker.run'
Tips and Limitations
Future and TODO's

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.