B
B
Bogdan Gerasimenko2017-08-15 17:29:39
PHP
Bogdan Gerasimenko, 2017-08-15 17:29:39

How to optimize mass mailing in PHP?

Good day,
I'm writing a function for mass mailing messages over the SOAP protocol. There is a function that parses values ​​from JSON and sends them in a foreach loop:

$sms = json_decode($response);
foreach($sms->data as $mydata)      
{
    $client->sendSmsOne($sessid, $mydata->phone, $mydata->from, $mydata->text);
}

If there are about 100 recipients, it turns out that the function will try to do this in one pass. Something like 100 sends per second. Will my server hang? And how to optimize, or rather properly organize this mailing process? Through the do-while function or pause after each processing?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Night, 2017-08-15
@Kleindberg

Will not hang. do not worry.
In the worst case, it will fall into a max execution time error if it is not a cli.
To optimize something, you need to know what exactly, first determine the problem that you want to optimize.

K
kirBurkhanov, 2017-08-15
@kirBurkhanov

Use queues that you will store in the database, the same mysql is most likely quite suitable for your tasks.
Better yet, use frameworks where everything has already been thought of for you. Laravel is easy enough to get into and very functional.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question