B
B
BonBon Slick2018-07-04 15:04:52
symfony
BonBon Slick, 2018-07-04 15:04:52

Process vs ReactPhP?

https://symfony.com/doc/current/components/process.html
or
https://github.com/reactphp/
Which is better? When? Why? Are there any good samples, github or somewhere else?
I know that there are more
https://stackoverflow.com/questions/70855/how-can-...
https://habr.com/post/300952/
and
php.net/manual/ru/class.thread.php
Examples :
1 - chat
2 - download, file processing
3 - Queue that processes records in the database, and let them be 10,000,000 there
UPD. my personal task is to process audio by crown, there are hundreds of audio files, maybe thousands in the future. Processing 1 audio file 5-15 minutes. If you just shove each track into the queue for a crown, what's the point? It will be like in a queue, the second track will wait until the first one is processed, the third second, and so on. In addition, the queue is already full of emails, notifications, and other features. If emails can wait, but make the user wait for their audio to be processed, well, I wouldn't like to wait 15 minutes for my audio to be processed. Therefore, the question of multithreading arose, I don’t want to load the project with unnecessary modules like node, there’s nothing to do now. Therefore, the question became how to process several records / files at the same time. Which package is best?
It doesn’t come out to find it and so to compare it, but it’s vaguely like it comes out to compare on the docks.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
voronkovich, 2018-07-04
@BonBonSlick

Asynchrony is only good for fast, non-computational tasks . In your case, the first running task will take the processor for 5-15 minutes, the rest will wait, which will be equivalent to their sequential launch.
It's best to use queues like beanstalkd and the like.
Old school variant. If there are several hundred files, they can be processed by running 10-50 processes in parallel, depending on the amount of RAM (fork/exec/wait). You can use a library like spatie/async for this .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question