The use of PHP real multithreading
PHP 5.3 versions, using pthreads PHP extensions, enabling them to truly support multithreading. Multithreaded processing of repetitive tasks can greatly shorten the execution time.
my previous article said that the performance bottlenecks of most sites are not on the PHP server, because it can be easily handled by increasing the number of servers or CPU kernel horizontally (for a variety of cloud hosts, adding VPS or CPU kernel numbers is more convenient, directly using a backup image to increase VPS, even operating systems, Instead of installing the configuration, the environment is based on the MySQL database. If you use the MySQL database, a SQL with a joint query, you may be able to process the business logic, but you will be able to stop eating when you encounter a large number of concurrent requests. If you use a NoSQL database, you may need ten queries to finish the same business logic, but each query is faster than MySQL, and the ten loop NoSQL query may be faster than a MySQL joint query, and it's absolutely no problem dealing with tens of thousands of seconds / seconds. If we add PHP multithread, we can query the NoSQL through ten threads at the same time and return the result to output. In our actual APP products, we call a PHP interface that recommends goods in real time through user preferences, and PHP needs to initiate a 500~1000 query on the BigSea NoSQL database to calculate the user's personality preferences in real time, and the role of PHP multithreading is very obvious.
PHP extension Download: https://github.com/krakjoe/pthreads
PHP manual document: http://php.net/manual/zh/book.pthreads.php
1, extended compilation and installation (Linux), edit parameter --enable-maintainer-zts is an essential option:
[code]cd / Data/tgz/php-5.5.1
make clean
make
make install
make
make install[/code]
[code]vi /Data/apps/php/etc/php.ini[/code]
Add:
[code]extension =.Quot;