title: Rails network calls extremely slow from Sneakers worker
body: <p>I have a doozy of a problem right now and would be very happy with any ideas folks might have.  </p>
  
  <p>The problem:  Network calls are very slow (Redis, HTTP) when running in a Sneakers worker. For example, setting a key in redis is taking ~20 seconds, and an HTTP get call ~38 seconds.  From the <code>rails c</code> the same redis call takes &lt; 1 second and the HTTP call about a second.</p>
  
  <p>The set-up: Will try to be as concise as I can here.</p>
  
  <ul>
  <li>Everything is running in Docker (Rails + workers, Redis, Postgres etc..)</li>
  <li>Rails 4.2.7 is the main web app, using puma as as the web server</li>
  <li>There are two background jobs which are handled via Sneakers and triggered via RabbitMQ messages.  These "workers" include calls to classes inheriting from ActiveRecord which do the actual activities (i.e. make the HTTP call or interact with Redis)</li>
  <li>I have since simplified and only make a HTTP call within the Worker class (it does nothing else).  I have also moved it to the foreground for debugging.</li>
  </ul>
  
  <p>Puma is configured to run in "single" mode (no workers, 1 thread).  Here is my current Sneakers configuration:</p>
  
  <pre><code># config/initializers/02_sneakers.rb
    Sneakers.configure  daemonize: false,
                        amqp: "amqp://rabbitmq",
                        # log: "log/sneakers.log",
                        log: STDOUT,
                        pid_path: "tmp/pids/sneakers.pid",
                        threads: 2,
                        workers: 1,
                        durable: true,
                        vhost: '/',
                        exchange: 'exchange',
                        exchange_type: 'direct'
  
  Sneakers.logger.level = Logger::DEBUG
  </code></pre>
  
  <p>And my worker:</p>
  
  <pre><code>class StepWorker
    include Sneakers::Worker
    from_queue "queue", env: nil, timeout_job_after: 5.minutes, durable: true, ack: true
  
    def work(raw_event)
      logger.info { 'StepWorker received params: ' + raw_event }
      message = JSON.parse(raw_event)
  
      response = ""
      time = Benchmark.measure {
        response = RestClient.get('http://store/', { accept: :json })
      }
      logger.info { "response: #{response.length} in #{time.real}" }
  
      ack!
    end
  end
  </code></pre>
  
  <p>I also have an <a href="https://github.com/jondot/sneakers/issues/256" rel="nofollow noreferrer">issue</a> going with some folks on the Sneakers.  Any ideas are much appreciated!</p>