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
Slide 4
Slide 4 text
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
Slide 5
Slide 5 text
Example
Web App Messaging
Queue
Worker
Worker
Worker
Amazon SQS, IronMQ,
Beanstalkd, Gearman,
RabbitMQ, MSMQ
5
Wednesday, 28 November, 12
Slide 6
Slide 6 text
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
Slide 7
Slide 7 text
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
Slide 8
Slide 8 text
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
Slide 9
Slide 9 text
Benefits of PHP-Queue
• Backend agnostic.
• Flexible job queue implementation.
• 1 queue 1 type of jobs.
• 1 queue many types of jobs.
• Independent workers. Chainable.
• Powerful.
• REST server, CLI, daemons.
9
Wednesday, 28 November, 12
Slide 10
Slide 10 text
Demo
• Installation with Composer.
• Creating a Queue.
• Creating a Worker.
• Using the REST server.
• Using the CLI.
10
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