I seted my threshold: 1 and interval: 60 and I got a concurrency problem on exec_within_threshold method when I start 5 sidekiq processes:
(INFO) time=2018-04-24 15:08:25 -0300 Msg=Checking contact for {:payload=>{:users=>["+5511958122379"]}}.
(INFO) time=2018-04-24 15:09:26 -0300 Msg=Checking contact for {:payload=>{:users=>["+5511941016555"]}}.
(INFO) time=2018-04-24 15:10:27 -0300 Msg=Checking contact for {:payload=>{:users=>
(INFO) time=2018-04-24 15:11:27 -0300 Msg=Checking contact for {:payload=>{:users=>["+5519983014013"]}}.
(INFO) time=2018-04-24 15:11:27 -0300 Msg=Checking contact for {:payload=>{:users=>["+5511941016555"]}}.
(INFO) time=2018-04-24 15:11:27 -0300 Msg=Checking contact for {:payload=>{:users=>["+5511958122379"]}}.
(INFO) time=2018-04-24 15:12:28 -0300 Msg=Checking contact for {:payload=>{:users=>["+5519983014013"]}}.
(INFO) time=2018-04-24 15:13:28 -0300 Msg=Checking contact for {:payload=>{:users=>["+5511941016555"]}}.
my code is:
ratelimit.exec_within_threshold('check_contacts', threshold: 1, interval: 60) do
ratelimit.add('check_contacts')
logger.info { "Checking contact for #{@body}." }
### My code here
end
And executed:
[1259, 1258, 1257, 1258, 1257].each { |p| MyWorker.perform_async(p) }
It seems that process read my redis at same time and execute ignoring rate limit configuration.
I seted my
threshold: 1andinterval: 60and I got a concurrency problem on exec_within_threshold method when I start 5 sidekiq processes:my code is:
And executed:
It seems that process read my redis at same time and execute ignoring rate limit configuration.