What is a Queue? • Software engineering components used for inter-process communication. • They use a queue for messaging - the passing of control or of content between different parts of your software. • Asynchronous communication protocol. 3 Wednesday, 28 November, 12
Examples • Email/SMS/Push Notification delivery. • Processing uploaded photos/videos. • Pushing content to all the home feeds of a user’s friends. • Anything that takes a long time to process. 4 Wednesday, 28 November, 12
Benefits • Improve responsiveness of your web apps. • Reduce load of your web server/database. • Distribute workload to multiple threads & servers. • Helps you scale. 6 Wednesday, 28 November, 12
How about...? • Why not use a cron job? • Batch processed < time allocated (unused capacity) • Time taken > time allocated (overlap) • Why not use a normal MySQL table? • Not crash resistant (workers). Race conditions. 7 Wednesday, 28 November, 12
Why PHP-Queue? • Its not easy implementing a messaging queue. • Which backend? Hosted/Self-host? • Learning curve - protocols, libraries. • Not responsive to changing use cases. • Vendor locked-in. 8 Wednesday, 28 November, 12
Caveat • Please know what you are doing. • You have to maintain the queue server. • Monitor performance and adjust accordingly. • Secure it! 15 Wednesday, 28 November, 12