A
A
alex_belouss2017-07-02 08:45:22
PHP
alex_belouss, 2017-07-02 08:45:22

How to implement sending sms 100-500 sms at a time?

There is a customer base on the site. You need to send each of them a text message every six months. The database is filled gradually, a client was added today or his records were updated, six months is fixed from this moment. Thus, in the future, it may accumulate so that in one day you need to send 100 or 500 customers at a time.
I plan to do this, the last_updated date column is simply updated in the database.
And then cron will run a script every day, the script will pull out those records if last_updated is equal to or greater than 6 months. Let's say 100 records are pulled out. I send sms to each of them and update last_updated

(foreach $items as $item)
{
sendSms($iitem->phone);
// а здесь по айди item находим запись и обновляем last_updated
}

Is this the right decision? And what kind of failures can happen?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
E
Exploding, 2017-07-02
@alex_belouss

The most important thing is that you did not mention!)) Namely, the way to send SMS. Here everything rather depends on the service provider: the method of receiving data from you, if there are restrictions (maybe a timeout or number per day there, for example ...)
And forich you will go through them or with a file - in my opinion, in general, up to one place: )
For example: I use a service that allows you to directly connect to their database (there is a separate table for each client) and just insert as many SMS into it as my heart desires, at least 100 at least 1000 at least lyam (well, the funds on the account :) ), and then his problems are how he will send them. He received the data, "signed" - arividerchi :)

D
Dimonchik, 2017-07-02
@dimonchik2013

without premature optimization, the solution is correct
and so - think about what to do when the time for the next cron has come, but there is no information yet whether the SMS has been delivered

B
Bogdan, 2017-07-02
@bogdan_uman

Well, why not use ActiveRecord on rails, and thus you can manipulate data more efficiently

items = Item.all.where('last_updated <= ?', Time.now - 6.month).limit(100)

items.each do |item|
  sendSms(item.phone)
  item.update(last_updated: Time.now)
end

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question