Introducing the queue mechanism in Laravel
We will implement a simple use case in order to shed light on the asynchronous aspects and how much a queuing mechanism can improve the user experience for the end users of our web application.
For every request, a time-consuming task will be executed. To simulate the time-consuming task, we will call sleep()
to last 3 seconds. The sleep()
function, which suspends execution for a certain number of seconds, is intended to simulate the execution of a task that may take some time to implement. In a real case, the sleep()
function is replaced with complex business logic that could take a certain amount of time to complete.
With the synchronous approach, the request will hold the response to the browser for 3 seconds. As a user, you will request the page, wait for 3 seconds, and then the page will be shown. The page will contain the message that the operation is completed – so you are safe and sure that the process is correctly executed...