Concurrency Try it

limiter = RateLimit::Limiter.new(apikey: "ACCT_ID|APIKEY")

# only need to do this on startup
# allow 2 tokens to be taken out at once
# allow tokens to be returned
# if processes don't return their token in 30 sec, they will become available again
limiter.upsert_concurrency_limit("concurrent", 2, 30)

5.times do |i|
  Thread.new do
    begin
      limit_result = limiter.acquire_or_wait(key: "concurrent", acquire_amount: 1, wait_in_secs: 10)
      sleep(2)
      limiter.return(limit_result)
    rescue RateLimIt::WaitExceeded => e
      puts "never ran #{i}"
    end
  end
end