Message queue concept
##Essentially, the message queue is the middle of a queue structure That is to say, the message can be returned directly after being put into this middleware, and does not need to be processed immediately by the system. There will be another program to read the data and process it one by one in order. (Recommended learning:
PHP Video Tutorial)
That is to say, when you encounter a problem that is extremely concurrency and takes a long time and does not need to return the processing results immediately, you can use the message queue to solve it. These kind of questions. For the order process, we can design two systems, one is the "order system" and the other is the "delivery system". We should have seen it when shopping online. After I submitted an order, I You can see in the background that my goods are being delivered. At this time, a "delivery system" needs to be involved. If we design the "order system" and "delivery system" together when doing the architecture, there will be some problems. First of all, for the order system, the pressure on the system will be relatively high, but " The distribution system" does not necessarily have to respond immediately to these pressures. Secondly, we do not want the failure of the order system to cause a failure of the distribution system, which will affect the normal operation of both systems at the same time. So we hope to decouple these two systems. After the two systems are separated, we can communicate between the two systems through an intermediate "queue table".Architecture Design
First the order system will receive the user's order, and then process the order.
Then these order information will be written to the queue table. This queue table is the key to communicating between the two systems.
A program executed regularly by the distribution system to read the queue table for processing.
After the distribution system processes it, it will mark the processed records.
The above is the detailed content of How to use queues in php for applications. For more information, please follow other related articles on the PHP Chinese website!