Search code examples
ruby-on-railshttprequestsidekiq

Use sidekiq to limit request through Net::http request


In my rails app, I need to call a http API in other address (just call it "Server A"), but Server A cannot process too much request at the same time. So I need to limit query from my rails app by using a queue or connection pool, or something like that. First I use sidekiq, but there is not a good way to waiting for sidekiq complete in rails (I need to response inside rails request, this request can take a little longer but it is ok). Can anyone suggest me a solution for this situation?


Solution

  • Sidekiq does not have a way to rate limit external operations. Sidekiq Enterprise offers a rate limiting API which will do what you need.

    https://github.com/mperham/sidekiq/wiki/Ent-Rate-Limiting#concurrent