Deploy a Sidekiq Worker


In the course of processing web requests, you may have to offload tasks to an asynchronous, background process (typically called a worker). Render makes this easy to do through Background Workers, which work like any other service.

For this quick start, we’ll use Sidekiq, a popular task processing framework for Ruby, and the Sinatra example in Sidekiq’s official repo.

Sidekiq uses Redis for its processing backend, so we’ll set up a private Redis service first.


  1. Create a new private Redis server using the Redis deployment guide and make a note of the service address which will look like redis:10000.
  2. Fork render-examples/sidekiq on GitHub and create a new Background Worker using your repo and the following values:

    EnvironmentRuby
    Build Commandbundle install
    Start Commandbundle exec sidekiq -r ./main.rb

    Add the following environment variable under Advanced:

    KeyValue
    REDIS_URLredis://<redis-url>, where redis-url is the URL from step 1.
  3. Create a new Web Service using the same repo you created in Step 2, and the following values:

    EnvironmentRuby
    Build Commandbundle install
    Start Commandbundle exec ruby main.rb

    Add the following environment variable under Advanced:

    KeyValue
    REDIS_URLredis://<redis-url>, where redis-url is the URL from step 1.

    This will spin up a new Sinatra web service which you can use to test background message sending. The code uses Sidekiq’s API to send the message to your Redis instance, which is the same instance your background worker is listening on. As a result, the worker picks up and processes any messages you send from the frontend.

You can also use a Sidekiq background worker from Rails. See Sidekiq’s getting started page for more information.