I have a PHP script that connects to and queries multiple remote database servers. How can I ensure these connections and queries run in parallel instead of serially so as to minimize execution time and improve end user page rendering times. And also to avoid any database connection time outs from affecting the rest of the queries.
Ew PHP is not the way you want to do this. There are few techniques, like opening and immediately closing a web sockets that then write to a log file, and you basically have a function you call throughout the code to check this file. It’s as ugly as it sounds.
You might benefit better from using JavaScript, which can do asynchronous calls, and then update a file with an AJAX call. If the integer values you’re getting are used on the front end, you might not need PHP at all.