Home > Article > Web Front-end > Do you know when to use queue?
The content this article brings to you is about the circumstances under which queues are used. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
The main uses of queues are asynchronous tasks and communication.
Asynchronous ideas are mainly used to alleviate instantaneous pressure, time-consuming operations, parallel tasks, etc.
1. Relieve instantaneous pressure: If the system's processing capacity is 100 requests per second, and the highest peak value may reach 1,000 requests per second, if queues are not used, the service is likely to be unavailable or wait for a long time. At this time, you can use the queue to put the requests that have not been successfully executed into the queue, and execute them sequentially until all requests are processed
2. Time-consuming operation: thumbnail generation
3. Parallel tasks: Notify all friends after posting
The communication idea is mainly used to solve the time-consuming operations of synchronizing data between different independent modules or systems and notifying the execution of certain operations
, and if business requirements permit, it can be placed in an asynchronous queue, such as
1. Post Weibo and push the Weibo to your friend’s inbox (assuming the push method is used), similar to feed
2. When uploading images, thumbnails of different sizes must be generated
3. While posting, use Baidu Know API to synchronize a copy to Baidu Know
4.Send mass mail
The above is the detailed content of Do you know when to use queue?. For more information, please follow other related articles on the PHP Chinese website!