multithreading - How to realize Multi-Threading connection in PHP -


i have application developed in php. in app, have hundreds of systems in record. every 15 mins, need connect systems track status (like cpu usage), , return them web page. problem code connect each system , execute query command 1 one, makes program slow. now, takes more 15 mins track system status, means that, @ second 15 min, has not finished first time's query. there way connect systems in parallel in php? example, ssh first 10 systems using 1 thread, , in mean time, ssh 10 using thread. thanks.

put connection information (host names or ip addresses) of systems in array, loop on them , fork every system. after forking, execute queries towards system. every query happen in new thread, running asynchronously other queries. wait forked children finish work, exit script.

this work lot faster running every query synchronously since don't have wait every response before moving on next query.

depending on server specs , amount of remote systems, might want limit amount of threads created.


note: php pcntl not available windows (see here.)


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -