The use of PHP real multithreading

time:14-10-12 forum:PHP tools and code
  http://zyan.cc/pthreads/
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;
  • 2

prev:Free pit and fissure sealing for 70 thou... next:Ji'nan old age apartment occupancy rate ...
post comment
Notice



approved   Chinese girls spend 4 years designin...   Chongqing version of "peach sister":...   Returnees in mountainous areas suppo...   Where is the old Ji'nan? More than 3...   A small set of fingers can adjust th...
rand   AJAX uses cookie to transmit values   The solution to the problem of chaot...   PHP AJAX implements no refresh page ...   A summary of the method of generatin...   PHP paging code, suitable for use in...
ads

other

Because all the contents of this site are reproduced from other media, the intention is to provide free services to the public, but it does not mean that this site agrees with its views, and can not be responsible for the authenticity of its verification, such as the copyright unit or individual of the manuscript does not want to publish on this site, please Contact me, I will immediately remove it, thank you. Contact: atseashawk@163.com