Swoole provides asynchronous multi-threaded server for PHP language, asynchronous TCP/UDP network client, asynchronous MySQL, database connection pool, Asynctask, message queue, millisecond timer, asynchronous file read-write, asynchronous DNS query.
Swoole have heard before, take to do game server is an artifact ... I feel a little bit today, I built the environment under Ubuntu and tested
Test code:
| The code is as follows |
Copy Code |
|
<?php
Class Page extends Controller
{
function index ()
{
; $data = Createmodel (' UserInfo ')->get ()->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/second
time per Reque St (mean)
time per request (mean, across all concurrent requests) |
Operation mode
Swoole eventtcp swoole selecttcp swoole blocktcp
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 also has such a good efficiency, to keep a paw. Easy to use later