Reputation: 879
I found that pthreads
does not work on web environment. I use PHP7.1 on FPM on Linux Debian which i also use Symfony 3.2
. All I want to do is, for example:
PUT
a file (which is 1GB)true
to user (jsonResponse
) without awaiting processing uploaded fileNow. For this I created Console Command
. I execute a Process('bin/console my:command')->start();
from background and I do my processing. But this is killing a fly with bazooka for me. I have to pass many variables to this executable command.
All I want to is creating another thread and just return to user without awaiting processing.
You may say this is duplicate. And point to pthreads
. But pthreads stated that it is only intended for CLI. Also last version of pthreads doesn't work with symfony. (fatal error).
I am stuck at this point and have doubt if should I stay with creating processes for each uploaded file or move to python -> django
Upvotes: 3
Views: 2885
Reputation: 316939
You don't want threads. You want a job queue. Have a look at Gearman or similar things.
Gearman provides a generic application framework to farm out work to other machines or processes that are better suited to do the work. It allows you to do work in parallel, to load balance processing, and to call functions between languages. It can be used in a variety of applications, from high-availability web sites to the transport of database replication events. In other words, it is the nervous system for how distributed processing communicates.
Upvotes: 3