What is the best method for sending mass messages to 1 million users in the database? What is the best method for sending mass messages to 1 million users in the database?
Reply content:
What is the best method for sending mass messages to 1 million users in the database?
Simplest: batch + Message Queue
Those that should be supported by SMS cloud, such as Alibaba Cloud. But certainly it cannot start from 1 million. it should be divided into batches. it is best to write a service to do this.
In fact, there are not many 1 million records. Currently, the SMS platform supports sending 1000 million records at a time. if you send them asynchronously, it will take several minutes. I have done similar things before, generate a temporary hash for the record you sent. in case of sending failure, you need to resend the record and cannot send it to the user repeatedly.
1. you can fetch IDs every 100 or 1000, which is fast.
2. concurrent sending will be involved here. For the multi-thread concurrency involved, see swoole workman.
2.1 The content can be repeated. The text message service provider can send 100 messages in batches.
2.2 if the content is not repeated, send it one by one
3. record the sending result and resend it regularly
Maximum number of messages that can be viewed per second
Then execute concurrently:
P1 & p2 & p3 & waitp4 & p5 & p6 &...