jeudi 1 août 2019

execute PHP SMS function concurrently

I have been working on a Bulk SMS product and recently we have been having challenges on the number of SMS sent at a time. We have tried several ways to optimize but 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 possible.

Is there anyway I can make my code execute the function 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?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire