PHP implementation of timed push messages (given appointment time, 10 minutes in advance, push reminder messages to users)

1. Currently, crontab, which comes with centos, automatically executes scripts. But there will be some errors in time.
the logic now is: the php code automatically queries the work order to compare the first 10 minutes of the current time with the appointment time. Push Wechat messages when the conditions are met. It consumes too much resources.
2. I don"t understand the message queue. I"m learning ing.
solution
under the guidance of logic to give some ideas, thank you.

Php
Jun.14,2022

this is the simplest and most convenient way to implement. You can't see where resources will be consumed. Using crontab should note that if the last task is not finished, how to handle the current task needs to be considered. It can be changed to a resident memory program (recommended), or you can check whether the last task has been completed before executing the logic.

the above processing scheme can be optimized. Check and push are handled separately. Using message queue docking, the data flow is: checker-> message queue-> push program-> Wechat

in which the inspector deals with the database, if there is too much data to be processed, start multiple examiners (multi-process / multi-thread), split the original data, and different programs finish processing the message queue.

if there is a bottleneck in the processing of the message pusher, directly expand the capacity horizontally and compete to consume the data in the message queue.


make an asynchronous queue

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e5e1e2-67126.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e5e1e2-67126.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?