A
A
Alex Smith2018-04-23 12:13:52
Laravel
Alex Smith, 2018-04-23 12:13:52

Where can I clearly read how queues work in Laravel?

The task is as follows:
When a user executes a request on the site, several simultaneous and sequential parsers are launched, according to the results of their work, it is necessary to give the result to the user.
Example:
The user made a request -> "Parser1" worked, it worked for 20 seconds, as a result of his work, data was received that are used in 4 subsequent parsers ("Parser2", "Parser3", "Parser4", "Parser5"), which are necessary, to work at the same time. Each of the last 4 parsers takes 12-14 seconds on average.
Accordingly, the request time for the user will be 20+(12~14) seconds = 32(~34) seconds.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yan-s, 2018-04-23
@Yan-s

What's the question?

T
Tesla, 2018-04-23
@Tesla

How queues work is quite clearly described in the documentation. You put the first task in the queue for execution. And when it is completed, it will also launch 4 other tasks in the queue. Of course, you must have several workers. But what happens in the queues, the script will no longer recognize. In order to get some results from them, you need to write the results to some database and monitor this very database in parallel, waiting for the results.
In your case, it's easier to run 4 threads in parallel using curl. Make 4 separate urls for parsers 2-5, and pull them with a curl when parser1 does its job. Curl and multithreading are easy to google.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question