Skip to content

How to aggregate data processed in parallel with pcntl  #259

@fiasco

Description

@fiasco

I want to complete independent processing in parallel to speed up the time it takes to complete an operation. I have a CLI (Symfony Console) tool that initiates a collection of independent processing tasks. I currently use PCNTL to fork each process but then have the challenge of returning the processed data back to the parent process.

I built a library with the help of phpreact. This library forks a socket server which the child forks can send their data too and the parent thread can poll it and retrieve the processed data when complete.

This feels more like a workaround than a solution and I'm wondering if there is a simpler way to do this? From what I can see, reactphp is only asynchronous in that it can continue php scripts while awaiting the response from a stream but can't actually run php itself asynchronously like pcntl does?

One thought is that I rearchitect my CLI tool so that reactphp calls CLI sub-commands via processes and in doing so creates streams I can wait for asynchronously. But I was hoping to utilise the forked memory state of the parent to reuse pre-processed data that all children use.

Anyway, appreciate your thoughts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions