M
M
Misty Hedgehog2016-11-07 21:41:10
Message Queues
Misty Hedgehog, 2016-11-07 21:41:10

Long running task in Laravel?

Good day, friends.
Not so long ago, I started using Laravel, and I already have a task from the customer, which can be formulated as follows: "I want to be able to upload a large amount of data (data about goods) to the database, and so that some fields are filled in automatically (in particular, a third-party resource is parsed , containing the price of the product by its code)". I sketched a product model, described its web api, screwed it to the gui, and the final touch remained - a method for adding a product to the database with parsing its data from a third-party resource. Previously contacted the customer, clarified about the changes in those. assignments and showed the front. He is pleased, but utters the sacramental "Only one small but - goods will be added in the amount of three hundred to four hundred thousand items at a time. And so that you don't have to keep the tab open."
Those. by and large, you need to upload the file to the server, parse it into an array, and process each element of the array one by one. But what is the best way to do this, so that the level of "collective farm" is minimal, and the process in the background does not have time to work out - it does not die, and the head does not hurt with the validations of this process? After all, even artisan db:seedthree hundred thousand records takes about fifteen minutes.
How can this problem be solved? Tell me please.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene Budnik, 2016-11-07
@paramtamtam

Queues must be used https://laravel.com/docs/5.3/queues

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question