Php asynchronous multi-thread swoole usage example, multi-thread swoole. Php asynchronous multi-thread swoole usage example. multithreading swoole this article describes php asynchronous multi-thread swoole usage. Share it with you for your reference. The specific analysis is as follows: swoole redefined php asynchronous multi-thread swoole usage instance, multi-thread swoole
This example describes the usage of php asynchronous multi-thread swoole. Share it with you for your reference. The specific analysis is as follows:
Swoole redefined the high-performance network communication framework of the PHP language and provided the asynchronous multi-thread service of the PHP language. the following example can prove this function.
In general, Swoole provides PHP asynchronous multi-thread server, asynchronous TCP/UDP network client, asynchronous MySQL, database connection pool, AsyncTask, message queue, millisecond timer, asynchronous file read/write, asynchronous DNS query.
Swoole has heard of it before. the server used to play games is simply an artifact... Today, I felt a little bit, set up the environment in ubuntu, and tested it.
The specific test code is as follows:
The code is as follows:
<? Php
Class page extends Controller
{
Function index ()
{
$ Data = createModel ('userinfo')-> get (12)-> get ();
$ This-> swoole-> tpl-> assign ('data', $ data );
$ Html = $ this-> swoole-> tpl-> fetch('test.html ');
$ Time = $ this-> showTime ();
Return $ html. $ time;
}
}
Shell
AB-c 100-n 1000-k http: // 127.0.0.1/index/
Requests per second
Time per request (mean)
Time per request (mean, processing SS all concurrent requests)
Running mode:
Swoole EventTCP Swoole SelectTCP Swoole BlockTCP Apache/Prefork
Single process
571.70 [#/sec] 174.916 [MS] 1.749 [MS] 659.01 [#/sec]
151.743 [MS]
1.517 [MS]
561.24 [#/sec]
178.178 [MS]
1.782
80.57
1241.083 [MS]
12.411 [MS]
4. process
1153.63 [#/sec]
86.683 [MS]
0.867 [MS]
1010.08 [#/sec]
99.002 [MS]
0.990 [MS]
1094.58 [#/sec]
91.359 [MS]
0.914 [MS]
Apache has such a high efficiency, and it will be useful in the future.
I hope this article will help you with PHP programming.
Examples in this article describes the usage of php asynchronous multi-thread swoole. Share it with you for your reference. The specific analysis is as follows: swoole redefinition...