Skip to content

Commit

Permalink
Improve workers and prefetch
Browse files Browse the repository at this point in the history
  • Loading branch information
Plakhotnikov Vladimir committed May 10, 2023
1 parent 3f89448 commit 4fd11ba
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion emitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

$len = count($queues);

for ($i = 0; $i <= 5000; $i++) {
for ($i = 0; $i < getenv('NUM_WORKERS'); $i++) {
$q = random_int(0, $len - 1);

$job = $queues[$q]->create('test-1', '{"site": "https://example.com"}');
Expand Down
2 changes: 1 addition & 1 deletion monitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@
}
}

sleep(1);
sleep(3);
}
10 changes: 5 additions & 5 deletions rr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
driver: amqp
config:
queue: queue-1
prefetch: 10
prefetch: 100
priority: 0
durable: true
exchange_durable: true
Expand All @@ -44,7 +44,7 @@ jobs:
driver: amqp
config:
queue: queue-2
prefetch: 10
prefetch: 100
priority: 0
durable: true
exchange_durable: true
Expand All @@ -54,7 +54,7 @@ jobs:
driver: amqp
config:
queue: queue-3
prefetch: 10
prefetch: 100
priority: 0
durable: true
exchange_durable: true
Expand All @@ -64,7 +64,7 @@ jobs:
driver: amqp
config:
queue: queue-4
prefetch: 10
prefetch: 100
priority: 0
durable: true
exchange_durable: true
Expand All @@ -74,7 +74,7 @@ jobs:
driver: amqp
config:
queue: queue-5
prefetch: 10
prefetch: 100
priority: 0
durable: true
exchange_durable: true
Expand Down
4 changes: 1 addition & 3 deletions worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
$consumer = new Consumer();

while (($task = $consumer->waitTask())) {
$random = random_int(50, 1000);

usleep($random * 1000);
sleep(10);

$task->complete();
}

0 comments on commit 4fd11ba

Please sign in to comment.