1 (edited by brent 2015-12-22 01:38:10)

Topic: Using pthreads with php-fpm

Hi all,

I'm creating a solution in PHP where a script will execute potentially hundreds of SNMP queries in order to build a single report for the end user. Often these SNMP queries will timeout and this is what I want to report on. It's currently going through an array of hosts and performing this task sequentially but it's very slow.

I saw pthreads and it seemed like a viable solution to do this in parallel. Unfortunately, I am running a Nginx w/ PHP-FPM setup and I found ZTS was required to use the pthread module. Is there any reason why PHP-FPM and ZTS don't go together? Is there an alternative (potentially better solution) within PHP I should be using or should I consider raising the request as an external python script or so (perhaps run and email enduser)

Using php-fpm from remi-php70 repo on Centos 7.2

Re: Using pthreads with php-fpm

AFAIK, phtreads extension is only for CLI mode.

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: Using pthreads with php-fpm

That's unfortunate. Any alternative suggestion? I've made a side perl script which is using creating 250 procs for Parallel::loops to complete the same function. Is it best I just run this from PHP?

Re: Using pthreads with php-fpm

Such a process in a web environment seems frightening...

Yes, having a side command seems better (written in perl or in php, as you prefer)

Sorry, no better idea.

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi