webman(235.29 [#/sec])的性能是Yii2.0 (72.91 [#/sec])的三倍+

分类:PHP |


非基准测试, 连接数据的情况下: 

事实上当测试仅返回 helloworld 时, 

webman:  12000/sec 左右

golang:  10000/sec   左右

java:  8000/sec  左右



Yii2 测试: 

╰─ ➜ ~ ab -c100 -n10000 http://yii2test.com/mobile/web/                                                                            
This is ApacheBench, Version 2.3 <$Revision: 1826891 $>                                                                       
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/                                                      
Licensed to The Apache Software Foundation, http://www.apache.org/                                                            
                                                                                                                              
Benchmarking yii2test.com (be patient)                                                                                             
Completed 1000 requests                                                                                                       
Completed 2000 requests                                                                                                       
Completed 3000 requests                                                                                                       
Completed 4000 requests                                                                                                       
Completed 5000 requests                                                                                                       
Completed 6000 requests                                                                                                       
Completed 7000 requests                                                                                                       
Completed 8000 requests                                                                                                       
Completed 9000 requests                                                                                                       
Completed 10000 requests                                                                                                      
Finished 10000 requests                                                                                                       
                                                                                                                              
                                                                                                                              
Server Software:        xx                                                                                                    
Server Hostname:        yii2test.com                                                                                               
Server Port:            80                                                                                                    
                                                                                                                              
Document Path:          /mobile/web/                                                                                          
Document Length:        6 bytes                                                                                               
                                                                                                                              
Concurrency Level:      100                                                                                                   
Time taken for tests:   137.165 seconds                                                                                       
Complete requests:      10000                                                                                                 
Failed requests:        0                                                                                                     
Total transferred:      4540000 bytes                                                                                         
HTML transferred:       60000 bytes                                                                                           
Requests per second:    72.91 [#/sec] (mean)                                                                                  
Time per request:       1371.647 [ms] (mean)                                                                                  
Time per request:       13.716 [ms] (mean, across all concurrent requests)                                                    
Transfer rate:          32.32 [Kbytes/sec] received                                                                           
                                                                                                                              
Connection Times (ms)                                                                                                         
              min  mean[+/-sd] median   max                                                                                   
Connect:        0    0   0.4      0       7                                                                                   
Processing:    47 1367 248.6   1367    2379                                                                                   
Waiting:       40 1366 248.6   1366    2379                                                                                   
Total:         47 1367 248.5   1367    2379                                                                                   
                                                                                                                              
Percentage of the requests served within a certain time (ms)                                                                  
  50%   1367                                                                                                                  
  66%   1465                                                                                                                  
  75%   1528                                                                                                                  
  80%   1570                                                                                                                  
  90%   1682                                                                                                                  
  95%   1769                                                                                                                  
  98%   1884                                                                                                                  
  99%   1971                                                                                                                  
 100%   2379 (longest request)


webman测试:

╰─ ➜ ~ ab -c100 -n10000 http://127.0.0.1:8787/webman/                                                                          
This is ApacheBench, Version 2.3 <$Revision: 1826891 $>                                                                       
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/                                                      
Licensed to The Apache Software Foundation, http://www.apache.org/                                                            
                                                                                                                              
Benchmarking 127.0.0.1 (be patient)                                                                                           
Completed 1000 requests                                                                                                       
Completed 2000 requests                                                                                                       
Completed 3000 requests                                                                                                       
Completed 4000 requests                                                                                                       
Completed 5000 requests                                                                                                       
Completed 6000 requests                                                                                                       
Completed 7000 requests                                                                                                       
Completed 8000 requests                                                                                                       
Completed 9000 requests                                                                                                       
Completed 10000 requests                                                                                                      
Finished 10000 requests                                                                                                       
                                                                                                                              
                                                                                                                              
Server Software:        workerman                                                                                             
Server Hostname:        127.0.0.1                                                                                             
Server Port:            8787                                                                                                  
                                                                                                                              
Document Path:          /webman/                                                                                               
Document Length:        4 bytes                                                                                               
                                                                                                                              
Concurrency Level:      100                                                                                                   
Time taken for tests:   42.500 seconds                                                                                        
Complete requests:      10000                                                                                                 
Failed requests:        0                                                                                                     
Total transferred:      1240000 bytes                                                                                         
HTML transferred:       40000 bytes                                                                                           
Requests per second:    235.29 [#/sec] (mean)                                                                                 
Time per request:       425.001 [ms] (mean)                                                                                   
Time per request:       4.250 [ms] (mean, across all concurrent requests)                                                     
Transfer rate:          28.49 [Kbytes/sec] received                                                                           
                                                                                                                              
Connection Times (ms)                                                                                                         
              min  mean[+/-sd] median   max                                                                                   
Connect:        0    0   0.9      0      62                                                                                   
Processing:    10  421 366.9    326    2204                                                                                   
Waiting:       10  420 366.9    326    2204                                                                                   
Total:         10  421 366.9    326    2204                                                                                   
                                                                                                                              
Percentage of the requests served within a certain time (ms)                                                                  
  50%    326                                                                                                                  
  66%    497                                                                                                                  
  75%    613                                                                                                                  
  80%    696                                                                                                                  
  90%    921                                                                                                                  
  95%   1182                                                                                                                  
  98%   1427                                                                                                                  
  99%   1554                                                                                                                  
 100%   2204 (longest request)



以上是基于相同环境下, php,mysql版本均同一环境, 10个sql 查询的方法内进行的 100并发, 10000次请求进行的测试


Yii2.0+  测试结果: 

Concurrency Level:      100                                                                                                   
Time taken for tests:   137.165 seconds                                                                                       
Complete requests:      10000                                                                                                 
Failed requests:        0                                                                                                     
Total transferred:      4540000 bytes                                                                                         
HTML transferred:       60000 bytes                                                                                           
Requests per second:    72.91 [#/sec] (mean)                                                                                  
Time per request:       1371.647 [ms] (mean)                                                                                  
Time per request:       13.716 [ms] (mean, across all concurrent requests)                                                    
Transfer rate:          32.32 [Kbytes/sec] received

webman 测试结果: 

Concurrency Level:      100                                                                                                   
Time taken for tests:   42.500 seconds                                                                                        
Complete requests:      10000                                                                                                 
Failed requests:        0                                                                                                     
Total transferred:      1240000 bytes                                                                                         
HTML transferred:       40000 bytes                                                                                           
Requests per second:    235.29 [#/sec] (mean)                                                                                 
Time per request:       425.001 [ms] (mean)                                                                                   
Time per request:       4.250 [ms] (mean, across all concurrent requests)                                                     
Transfer rate:          28.49 [Kbytes/sec] received


综上, webman(235.29 [#/sec])的性能是Yii2.0 (72.91 [#/sec])的三倍+   


得空再测试下golang与webman的性能对比: 



web框架对比: 

https://www.techempower.com/benchmarks/#section=data-r21&hw=ph&test=db&l=zijnjz-sf&a=2



以下转自: https://www.workerman.net/plugin/11

多应用域名绑定插件 

https://github.com/webman-php/domain

简介

webman多应用域名绑定插件,可以给每个应用绑定独立的域名,并且支持url地址简写。
关于多应用请参考手册 多应用

安装

composer require webman/domain

使用

域名和应用绑定关系在 plugin/webman/domain/app.php中设置。

配置说明

return [
    'enable' => true, // 是否开启插件
    // 多应用绑定关系
    'bind' => [
        'abc.com' => '', // 不属于任何应用
        'a.abc.com'  => 'admin', // 绑定到admin应用
        'blog.abc.com'  => 'blog', // 绑定到blog应用
    ],
    // 绑定关系,域名,应用的验证逻辑,返回true时认为符合绑定关系,反之不符合返回404
    'check' => function ($bind, $domain, $app) {
        return isset($bind[$domain]) && $bind[$domain] === $app;
    }];

bind
域名和应用的绑定关系

check
当前域名和应用是否一致的检测函数(可根据需要修改),返回false说明不一致,则页面显示404。

短url

配置好多域名后,有时候我们想简写url。例如 a.abc.com 与 admin应用绑定,原来 a.abc.com/admin/user/get 简写为 a.abc.com/user/get,这时候我们可以通过nginx rewrite功能来做到。例如 a.abc.com nginx配置如下

upstream webman {
  server 127.0.0.1:8787;
  keepalive 10240;}server {
    listen 80;
    server_name a.abc.com;
    access_log off;
    root /your/webman/public;

    location / {
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header Host $host;
      proxy_http_version 1.1;
      proxy_set_header Connection "";
       if (!-f $request_filename){
          rewrite ^/(.*)$ /admin/$1 break;
          proxy_pass http://webman;
       }
    }}