Answer the question
In order to leave comments, you need to log in
How to synchronize the site with the worker server?
There is a site on PHP+MySQL. On this site, users create tasks and then run them.
A task is the performance of certain actions. Average task completion time is 5-6 hours.
When a task is started, a worker (Gearman) is launched in the background and then a client is hung on this worker.
It happens like this:
exec("php task/run/test.php > /dev/null &");
$client = new GearmanClient();
$client->addServer();
$client->doBackground('test', json_encode($data));
Answer the question
In order to leave comments, you need to log in
I am by no means a developer, but perhaps these tools will help you.
1 if there are many entries in the database and readings are an order of magnitude smaller, then look at the TokuDB engine from Percona
2 you can also build an architecture around a message broker, for example, rabbitmq, it will have queues for different things - new tasks from the site go in a queue from there, a script picks them up and starts the workers that perform the task, the status of the tasks and the results of the workers can also be placed in other queues, and from there they are already taken to the site in the database or somewhere else. Why is this even necessary? - The queue of tasks and data is a buffer that allows you to spread the load over time. For example, the results are not written directly to the database, but first to the queue, and on the database server, the worker reads the queue and puts the data into the database, while monitoring the load on the database and preventing overload.
Use a message queue between client and server. Thus, you will untie the architectural client and workers and will be able to regulate the load on the system. For the message queue, it is better to take a ready-made solution, although you can write it yourself.
There are even more advanced data flow processing systems, such as Hadoop.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question