fecshop 性能测速

技术分享 · Fecshop · 于 15天前 发布 · 194 次阅读

ab测试

装apache 的AB

1ubuntu安装AB:

`sudo apt-get install apache2-utils`

2.centos安装ab:

yum -y install httpd-tools

安装后就可以开始测试

1.硬件:阿里云机器,1核cpu,4g内存(上面有很多其他的网站应用,因此可以看成3G的内存)

2.php-fpm

pm = dynamic
pm.max_children = 20
pm.start_servers = 10
pm.min_spare_servers = 10
pm.max_spare_servers = 20

3.阿里云上面还有其他的一些站点,另外还开了一个php5.4,因此资源虽然是4G,但是用于测试的可能3G内存都不到

4.用于测试的url

4.1:在controller部分直接返回数据的url , http://fecshop.appfront.fancyecommerce.com/customer/test/test

public function actionTest(){
        echo 12;exit;
    }

4.2:fecshop appfront部分的产品链接:http://fecshop.appfront.fancyecommerce.com/alluring-long-sleeve-open-back-draped-maxi-dress-55525232

5.以上测试是本地测试,没有网络开销

测试1

php.ini没有开启opcache,fecshop没有开启缓存

1.测试一下初始化:http://fecshop.appfront.fancyecommerce.com/customer/test/test(这个url在controller中进行输出后,直接exit)

[root@iZ942k2d5ezZ ~]# ab -n 50 -c 10 http://fecshop.appfront.fancyecommerce.com/customer/test/test
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking fecshop.appfront.fancyecommerce.com (be patient).....done


Server Software:        nginx
Server Hostname:        fecshop.appfront.fancyecommerce.com
Server Port:            80

Document Path:          /customer/test/test
Document Length:        2 bytes

Concurrency Level:      10
Time taken for tests:   3.579 seconds
Complete requests:      50
Failed requests:        0
Write errors:           0
Total transferred:      18150 bytes
HTML transferred:       100 bytes
Requests per second:    13.97 [#/sec] (mean)
Time per request:       715.731 [ms] (mean)
Time per request:       71.573 [ms] (mean, across all concurrent requests)
Transfer rate:          4.95 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       0
Processing:    56  682 111.5    692     842
Waiting:       51  680 112.7    692     842
Total:         57  682 111.4    692     842

Percentage of the requests served within a certain time (ms)
  50%    692
  66%    713
  75%    731
  80%    758
  90%    781
  95%    818
  98%    842
  99%    842
 100%    842 (longest request)

结果:13.97 [#/sec]

2.

ab -n 50 -c 10 http://fecshop.appfront.fancyecommerce.com/alluring-long-sleeve-open-back-draped-maxi-dress-55525232

结果:

[root@iZ942k2d5ezZ ~]# ab -n 50 -c 10 http://fecshop.appfront.fancyecommerce.com/alluring-long-sleeve-open-back-draped-maxi-dress-55525232
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking fecshop.appfront.fancyecommerce.com (be patient).....done


Server Software:        nginx
Server Hostname:        fecshop.appfront.fancyecommerce.com
Server Port:            80

Document Path:          /alluring-long-sleeve-open-back-draped-maxi-dress-55525232
Document Length:        78750 bytes

Concurrency Level:      10
Time taken for tests:   7.959 seconds
Complete requests:      50
Failed requests:        0
Write errors:           0
Total transferred:      3960848 bytes
HTML transferred:       3937500 bytes
Requests per second:    6.28 [#/sec] (mean)
Time per request:       1591.726 [ms] (mean)
Time per request:       159.173 [ms] (mean, across all concurrent requests)
Transfer rate:          486.02 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       0
Processing:   335 1517 188.8   1560    1690
Waiting:      243 1440 188.9   1495    1603
Total:        335 1517 188.8   1560    1690

Percentage of the requests served within a certain time (ms)
  50%   1560
  66%   1597
  75%   1604
  80%   1615
  90%   1640
  95%   1649
  98%   1690
  99%   1690
 100%   1690 (longest request)

结果:6.28 [#/sec]

可以看到,不做任何优化,性能是很差的

测试2,开启opcache

[opcache]
zend_extension=opcache.so
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=256
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.file_cache=/tmp

1.ab测试ab -n 50 -c 10 http://fecshop.appfront.fancyecommerce.com/customer/test/test

[root@iZ942k2d5ezZ ~]# ab -n 50 -c 10 http://fecshop.appfront.fancyecommerce.com/customer/test/test
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking fecshop.appfront.fancyecommerce.com (be patient).....done


Server Software:        nginx
Server Hostname:        fecshop.appfront.fancyecommerce.com
Server Port:            80

Document Path:          /customer/test/test
Document Length:        2 bytes

Concurrency Level:      10
Time taken for tests:   0.372 seconds
Complete requests:      50
Failed requests:        0
Write errors:           0
Total transferred:      18150 bytes
HTML transferred:       100 bytes
Requests per second:    134.48 [#/sec] (mean)
Time per request:       74.363 [ms] (mean)
Time per request:       7.436 [ms] (mean, across all concurrent requests)
Transfer rate:          47.67 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       0
Processing:     8   70  17.2     74      94
Waiting:        5   70  17.4     74      94
Total:          8   70  17.2     74      94

Percentage of the requests served within a certain time (ms)
  50%     74
  66%     80
  75%     83
  80%     84
  90%     88
  95%     90
  98%     94
  99%     94
 100%     94 (longest request)

结果:134.48 [#/sec],可以看到开启apc后,从 13.97 [#/sec]提升了近10倍的速度

2.

ab -n 50 -c 10 http://fecshop.appfront.fancyecommerce.com/alluring-long-sleeve-open-back-draped-maxi-dress-55525232

[root@iZ942k2d5ezZ ~]# ab -n 50 -c 10 http://fecshop.appfront.fancyecommerce.com/alluring-long-sleeve-open-back-draped-maxi-dress-55525232
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking fecshop.appfront.fancyecommerce.com (be patient).....done


Server Software:        nginx
Server Hostname:        fecshop.appfront.fancyecommerce.com
Server Port:            80

Document Path:          /alluring-long-sleeve-open-back-draped-maxi-dress-55525232
Document Length:        78750 bytes

Concurrency Level:      10
Time taken for tests:   3.381 seconds
Complete requests:      50
Failed requests:        0
Write errors:           0
Total transferred:      3960749 bytes
HTML transferred:       3937500 bytes
Requests per second:    14.79 [#/sec] (mean)
Time per request:       676.257 [ms] (mean)
Time per request:       67.626 [ms] (mean, across all concurrent requests)
Transfer rate:          1143.92 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       0
Processing:   153  634 131.1    642     894
Waiting:       79  580 128.1    585     843
Total:        153  634 131.1    642     894

Percentage of the requests served within a certain time (ms)
  50%    642
  66%    678
  75%    689
  80%    710
  90%    846
  95%    852
  98%    894
  99%    894
 100%    894 (longest request)
[root@iZ942k2d5ezZ ~]#

14.79 [#/sec]

6.28 [#/sec]14.79 [#/sec],产品页面的速度提升了一倍左右,但是还是并发不高

测试3

开启cache: @appfront/config/fecshop_local_services/Cache.php

设置enable 为 true

[root@iZ942k2d5ezZ ~]# ab -n 50 -c 10 http://fecshop.appfront.fancyecommerce.com/alluring-long-sleeve-open-back-draped-maxi-dress-55525232
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking fecshop.appfront.fancyecommerce.com (be patient).....done


Server Software:        nginx
Server Hostname:        fecshop.appfront.fancyecommerce.com
Server Port:            80

Document Path:          /alluring-long-sleeve-open-back-draped-maxi-dress-55525232
Document Length:        78750 bytes

Concurrency Level:      10
Time taken for tests:   0.510 seconds
Complete requests:      50
Failed requests:        0
Write errors:           0
Total transferred:      3960700 bytes
HTML transferred:       3937500 bytes
Requests per second:    98.00 [#/sec] (mean)
Time per request:       102.046 [ms] (mean)
Time per request:       10.205 [ms] (mean, across all concurrent requests)
Transfer rate:          7580.67 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       0
Processing:    51   99  17.8    102     131
Waiting:        9   66  13.1     66      85
Total:         51   99  17.9    102     131

Percentage of the requests served within a certain time (ms)
  50%    102
  66%    108
  75%    111
  80%    112
  90%    122
  95%    128
  98%    131
  99%    131
 100%    131 (longest request)

结果:98.00 [#/sec]

开启整页缓存后,效果还是很明显的,产品页面秒并发98

测试4 appserver这种api端

1.没有开启缓存

[root@iZ942k2d5ezZ ~]# ab -n 100 -c 10 http://fecshop.appserver.fancyecommerce.com/catalog/product/index?product_id=57c3aaa9f656f24f353bf56e 
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking fecshop.appserver.fancyecommerce.com (be patient).....done


Server Software:        nginx
Server Hostname:        fecshop.appserver.fancyecommerce.com
Server Port:            80

Document Path:          /catalog/product/index?product_id=57c3aaa9f656f24f353bf56e
Document Length:        4296 bytes

Concurrency Level:      10
Time taken for tests:   3.858 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      460100 bytes
HTML transferred:       429600 bytes
Requests per second:    25.92 [#/sec] (mean)
Time per request:       385.761 [ms] (mean)
Time per request:       38.576 [ms] (mean, across all concurrent requests)
Transfer rate:          116.48 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   11 100.0      0    1000
Processing:    13  286 341.0    215    3075
Waiting:       13  209 171.9    158    1467
Total:         13  296 347.4    238    3075

Percentage of the requests served within a certain time (ms)
  50%    238
  66%    278
  75%    304
  80%    327
  90%    632
  95%    734
  98%   1456
  99%   3075
 100%   3075 (longest request)

结果为:25.92 [#/sec]

2.appserver 开启cache

开启cache: @appserver/config/fecshop_local_services/Cache.php

设置enabletrue,如果没有这个文件,将@appfront/config/fecshop_local_services/Cache.php复制过去,然后设置enabletrue

注意,更改文件要重启下php,因为开启了opcache

[root@iZ942k2d5ezZ ~]# ab -n 100 -c 10 http://fecshop.appserver.fancyecommerce.com/catalog/product/index?product_id=57c3aaa9f656f24f353bf56e
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking fecshop.appserver.fancyecommerce.com (be patient).....done


Server Software:        nginx
Server Hostname:        fecshop.appserver.fancyecommerce.com
Server Port:            80

Document Path:          /catalog/product/index?product_id=57c3aaa9f656f24f353bf56e
Document Length:        1974 bytes

Concurrency Level:      10
Time taken for tests:   1.105 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      212900 bytes
HTML transferred:       197400 bytes
Requests per second:    98.52 [#/sec] (mean)
Time per request:       110.475 [ms] (mean)
Time per request:       11.048 [ms] (mean, across all concurrent requests)
Transfer rate:          188.20 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       1
Processing:     9   99  46.2     86     283
Waiting:        9   96  44.1     86     283
Total:         10   99  46.1     86     283

Percentage of the requests served within a certain time (ms)
  50%     86
  66%     89
  75%     92
  80%     94
  90%    179
  95%    233
  98%    277
  99%    283
 100%    283 (longest request)

可以看到速度提升到了98.52 [#/sec] ,开启cache,访问产品分类,速度提升还是很明显的。

总结:

php7.1, 2核3G的内存下。

1.Yii2框架,在开启opcache后,有一个质的提升,大约10倍的速度提升

2.fecshop可以通过开启opcache 和 fecshop缓存,,达到100.00 [#/sec]的并发

3.对于自己开发的一些api,也尽量的加缓存,增强并发

4.如果是线上服务器压测,因为有网络开销,像阿里云还有流量的限制,因此需要走内网测试,可以通过hosts,将访问的域名映射到127.0.0.1,然后在本机进行ab测试,譬如我添加的

vim /etc/hosts

127.0.0.1 localhost xunsearch elasticsearch1 fecshop.appfront.fancyecommerce.com fecshop.appserver.fancyecommerce.com

访问 fecshop.appserver.fancyecommerce.com 直接走本机,不走外部网络。

5.本部分只对开启opcache 和 fecshop缓存 后的并发数进行测试,而且是1核3G内存进行的测试,如果您的机器内存高,cpu数量多,可以多开php-fpm, 并发数会更高

6.其他的更多的性能提速的文档,参看:http://www.fecshop.com/doc/fecshop-guide/instructions/cn-1.0/guide-fecshop_online_speed.html

共收到 5 条回复
1楼 已删除.
2楼 已删除.
Fecshop#314天前 0 个赞
ab -n 100 -c 10

100个用户,持续访问10秒吧?

这个测试环境是手工搭建的(阿里云),不是docker,为了忽略网络延迟,在/etc/hosts中将域名映射到127.0.0.1

Fecshop#414天前 0 个赞

最近优化一下性能,将缓存部分完善起来。

Fecshop#58天前 0 个赞

http://www.laruence.com/2015/12/04/3086.html

开启了 HugePage , 性能又提升了,下面的测试,还是1核3G内存的阿里云(阿里云是4G内存,因为服务器有很多其他的应用,暂且定为3G内存)

appserver, 没有开启fecshop cache的ab测试结果

 [root@iZ942k2d5ezZ ~]# ab -n 100 -c 10 http://fecshop.appserver.fancyecommerce.com/catalog/category/index?categoryId=57bea0e3f656f275313bf56e&sortColumn=&filterAttrs=%7B%7D&filterPrice=
[1] 28123
[2] 28124
[3] 28125
[root@iZ942k2d5ezZ ~]# This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking fecshop.appserver.fancyecommerce.com (be patient).....done


Server Software:        nginx
Server Hostname:        fecshop.appserver.fancyecommerce.com
Server Port:            80

Document Path:          /catalog/category/index?categoryId=57bea0e3f656f275313bf56e
Document Length:        8628 bytes

Concurrency Level:      10
Time taken for tests:   2.241 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      903699 bytes
HTML transferred:       862800 bytes
Requests per second:    44.61 [#/sec] (mean)
Time per request:       224.150 [ms] (mean)
Time per request:       22.415 [ms] (mean, across all concurrent requests)
Transfer rate:          393.72 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       0
Processing:    72  222  25.1    221     310
Waiting:       17  173  22.1    175     206
Total:         72  222  25.1    221     310

Percentage of the requests served within a certain time (ms)
  50%    221
  66%    231
  75%    236
  80%    239
  90%    249
  95%    258
  98%    269
  99%    310
 100%    310 (longest request)
 
 

结果:Requests per second: 44.61 [#/sec] (mean)

开启fecshop cache

[root@iZ942k2d5ezZ ~]# ab -n 100 -c 10 http://fecshop.appserver.fancyecommerce.com/catalog/category/index?categoryId=57bea0e3f656f275313bf56e&sortColumn=&filterAttrs=%7B%7D&filterPrice=
[1] 28357
[2] 28358
[3] 28359
[root@iZ942k2d5ezZ ~]# This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking fecshop.appserver.fancyecommerce.com (be patient).....done


Server Software:        nginx
Server Hostname:        fecshop.appserver.fancyecommerce.com
Server Port:            80

Document Path:          /catalog/category/index?categoryId=57bea0e3f656f275313bf56e
Document Length:        8628 bytes

Concurrency Level:      10
Time taken for tests:   0.828 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      903601 bytes
HTML transferred:       862800 bytes
Requests per second:    120.84 [#/sec] (mean)
Time per request:       82.756 [ms] (mean)
Time per request:       8.276 [ms] (mean, across all concurrent requests)
Transfer rate:          1066.29 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       1
Processing:    26   81  19.0     83     143
Waiting:        7   61  15.7     62     110
Total:         26   81  19.1     83     143

Percentage of the requests served within a certain time (ms)
  50%     83
  66%     93
  75%     96
  80%     99
  90%    102
  95%    105
  98%    123
  99%    143
 100%    143 (longest request)

[1]   Done                    ab -n 100 -c 10 http://fecshop.appserver.fancyecommerce.com/catalog/category/index?categoryId=57bea0e3f656f275313bf56e
[2]-  Done                    sortColumn=
[3]+  Done                    filterAttrs=%7B%7D
[root@iZ942k2d5ezZ ~]# 
[root@iZ942k2d5ezZ ~]# 

结果:Requests per second: 120.84 [#/sec] (mean)

可以看到开启 HugePage 后,没有开启fecshop cache的情况下,由30多到了44.6 ,开启 fecshop cache的情况下,由98 到了120,性能提升了很多

鸟哥的php性能优化还有其他的一些细节,没有做配置。

因此开启hugePage对性能的提升还是很大的

Fecshop#68天前 0 个赞

上面的压测,是在阿里云本机进行的压测,去掉了网络开销的时间,如果用自己的本机电脑压测是不准确的,

因为:

1.网络延迟的问题

2.我的阿里云带宽比较小,各位不要压测我的连接,压测这种肯定压满带宽,阿里云会给堵塞(阿里云的带宽是要加钱才能加大的),今而结果是不准确的

添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
Your Site Analytics