I’d like to make a few requests per second to another method using,
for example, backgroundrb (any other suggestions are welcome as
I have considered using jRuby to enhance the use of threads and I’m
quite sure that’s the way to go. So what I’d like Rails to do is,
based on a value in a database, calculate the number of requests it
has to make in a certain timeframe. For example, when it has to make
300 requests in 60 seconds, I’d like Rails to execute the method in a
new thread every 200 milliseconds. It can be off by a bit, but I want
to make sure it has 25 requests done by 5 seconds and 150 by 30.
That’s important. It can’t be finished by 50 seconds and it can’t be
resting for a whole second, for example.
The only solutions I’ve found so far are basically making Rails
execute the method and then sleep for a given time, but that doesn’t
feel right. I’m not even sure whether that accepts a time in
I hope you can help. Thanks.