Answer the question
In order to leave comments, you need to log in
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:seed
three 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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question