-
Notifications
You must be signed in to change notification settings - Fork 12
/
lowkiq.rb
50 lines (35 loc) · 892 Bytes
/
lowkiq.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# require 'bundler/setup'
# Bundler.require(:default)
$jobs_count = 100_000
Lowkiq.build_scheduler = ->() { Lowkiq.build_seq_scheduler }
Lowkiq.redis = ->() { Redis.new url: ENV.fetch('REDIS_URL'), driver: :hiredis }
module Worker
extend Lowkiq::Worker
# self.shards_count = 50
def self.perform(payloads_by_id)
end
end
Lowkiq.server_redis_pool.with do |redis|
redis.flushdb
end
jobs = (0...$jobs_count).map do |i|
{ id: i, payload: i.to_s }
end
jobs.each_slice(10_000) do |batch|
Worker.perform_async batch
end
puts "jobs are enqueued"
start = Time.now.to_f
Monitoring = Thread.new do
metrics = Lowkiq::Queue::QueueMetrics.new Lowkiq.client_redis_pool
loop do
len = metrics.call([Worker.queue_name]).first.length
puts len
if len == 0
total = Time.now.to_f - start
puts "total time: #{total}"
exit 0
end
sleep 1
end
end