S
S
Sergey Bard2017-05-15 21:24:18
PHP
Sergey Bard, 2017-05-15 21:24:18

How to run cron in turn?

Hello again). I'll try to write as accurately as possible what I want), In general, I'm making an application for myself,
it's better with an example, the user enters a link and the script collects a lot of information from analytics, etc. according to this link, so that the page does not give 504, I think that it is best after pressing the "Run" button or something similar (that's not the point), send this script to cron (I call it work))), and now when the script completes, it will display information on a separate page and inform the user that the collection of information is over (such as Request history).
And the question itself is how to make a queue of cron launches or something similar so that if two users run cron at the same time, then what would the cron work first for the first user, and then the second, or am I mistaken and this is not needed?
Maybe there are already special frameworks or something else for this, well, if I'm wrong, then correct me).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2017-05-15
@serg_small_developer

The task queue in PHP can be implemented in various ways. For example, the server and clients of Gearman (a "sparrow gun" for your task) or Queues in the Laravel framework.
By clicking the "Run" button, the entered link is simply saved. And in the background, a process (or several) is constantly running, waiting for tasks and processing them. This "worker" process, launched from the command line, can run indefinitely. Having completed one task, he immediately goes into the waiting mode for the next. There is already the following - immediately starts to run. Etc.
If 100 visitors almost simultaneously create their tasks, they will line up and be processed sequentially.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question