Answer the question
In order to leave comments, you need to log in
How to send several million messages in parallel?
Project on laravel, postgres, redis queue.
The database contains 10 million rows. You need to filter them by conditions and send them messages.
Current implementation:
function handle() {
Users::query()->chunk(100, function($users) {
$filterUsers = $this->filter($users);
foreach ($users as $user) {
$this->sendToUser($user, 'message');
// помечаем в бд что отправили
}
});
}
function filter($users) {
// опращаемся на врешний апи за инфой по юзерам
// фильтруем их по условиям из нашей бд
return $filterUsers;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question