I've got about 30 databases (on different machines) with the same structure and I want to query them with the same very query.
Normally I am preparing connections and then doing foreach
connecting to every database and sending query, waiting for result.
I was thinking about running those queries in parallel processes, so instead of waiting for results sum up (ie. 1 second per query per server), it would be a time of longest running query.
First I though about mysqli::poll
/ MYSQLI_ASYNC
, but it heavily depends on mysqli.
I've found similar question: PHP asynchronous mysql-query but it's over 3 years old. Maybe somebody found other way?
Only one independent solution I can think of right now is using pnctl_fork
to split queries to parallel processes, and then collect data using shared memory.
Is there any other method in PHP to work it around and achieve desired result?