Search code examples
ruby-on-railsruby-on-rails-4sidekiqcrystal-lang

How to reuse HTTP connection and share it between Sidekiq background jobs?


My app sends multiple API requests and get responses in background jobs to third party server. For now every job opens new Http connection and closes it after receiving a response. If it's possible to share this connection between all my app's jobs? How to keep it alive while a pool of jobs is in progress? How to close it at the end? Thanks.


Solution

  • This is what a connection pool is designed for.

    https://github.com/mperham/sidekiq/wiki/Advanced-Options#connection-pooling