jeudi 1 août 2019

How to execute a PHP code function concurrently for different processes. Sms scenario

I have been working on a Bulk Sms product and off-late we have been having challenges on the number of sms sent at a time. We have tried several ways to optimize both we have not yet reached a good solution.

Our provider provides provides an endpoint that sends a single SMS at once. We have a function that sends an SMS to that endpoint. Now lets say I have a user who has 10K contacts in a group, and we want to send SMS to that endpoint with the best time as possible.

Is there anyway i can make my code execute the function to concurrently while generating the SMS to my db table?

For example, lets assume the send sms function as sendSms($phone, $message)

Then lets generate the SMS from a group of 10K contacts:

foreach($group->contacts as $contact) {
 //from a controller
 $this->dispatch(new SendSmsJob($contact->phone, $contact->message))->onQueue('high');
}

Clearly the SMS will be created and queued lets say redis, but they are sent sequentially. Is it possible to do a concurrency? Is AWS lambda a solution? or Lavavel Vapor?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/32YBtkJ
via IFTTT

Aucun commentaire:

Enregistrer un commentaire