Use the power of a Amazon’s scalable queuing system in your Laravel 5 application
In this post, we’ll look at why you might use queues, and then have look at how you can get started quickly and cheaply with Amazon’s SQS (simple queue service), on AWS
For the most part, your Laravel 5 web application is responding to HTTP requests. If your app is simple, you’ll probably be doing some simple data manipulation, and then saving that information to a database. As your application grows in complexity, some routes in the system might start doing a decent chunk of work. Things that might take some time include:
As PHP and PHP executing web servers are generally used synchornously, waiting for all of these to complete before responding to the user’s request could take some time. An example request that uses some of these examples, is uploading a new profile photo:
In this example, steps 3 – 7 don’t need to have happened before we send the success message.
If we’ve validated the image size, then we can respond immediately to the user that their upload is “good”. We’ll then let the system handle the resizing and S3 uploads as and when they get to it. If something does go wrong at that point, we can email the user, or send them a notification in the app that something went wrong.