0

I want to use a queue for file uploads. Users can upload files. Each file will have around 500 rows. Now I want to implement this logic:

  • Maximum of 5 files can be processed at the same time. The remaining files should be in the queue.
  • Each file should have 5 processes, so 5 rows will be inserted into databases at the same time. Shortly, there are will be a maximum of 25 processes (5 processes in every 5 files).

Now I am adding all files to one queue. Files processing one by one. Shortly first-come, first out. 2nd file needs to wait to finish 1st file.

How can I implement this? Or do you have any other suggestions?

0

1 Answer 1

2

What exactly is the difference between processing a file, and inserting rows into the DB?

If you want to run multiple workers for the same queue, you can simply start more workers using php artisan queue:work and additionally use flags to specify the queues --queue=process-files for example. See the documentation.

In a production environment, consider to configure a supervisor to run a specific amount of workers on a queue using numprocs directive.

Do I understand correctly you want to run 25 queue workers per user? That does not seem right. Instead, you should consider creating queues for fast/slow jobs.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.