OpenCart 3.0基准测试

楚天乐 475 0 条

本片旨在测试当前环境下,opencart的benchmark。以方便对比后续常驻内存swoole版本的性能,得出优化成果。

环境

  1. web server,单台1核2g内存VPS
  2. 数据库MySQL 5.6,单独一台2核4g内存vps
  3. 在database上发起webbench测试

测试准备

  • 关闭opencart模板编译,关闭sccs编译
SET SQL_SAFE_UPDATES = 0;
UPDATE oc_setting SET value=1 WHERE `key` = "developer_theme";
UPDATE oc_setting SET value=1 WHERE `key` = "developer_sass";
SET SQL_SAFE_UPDATES = 1;
  • databse server上安装webbench。安装方法参照上一篇文章

开始测试

  • 测试100 clients,60 seconds
webbench -c 100 -t 60 http://swoole-opencart.shyclouds.com/

开着top看了下webserver的反应,nginx占37%cpu,php-fpm八进程平均1%cpu。我这是在给nginx做压测。。。
重新运行测试,试图打开网站,然而网站此时已经nginx 502错误了。

解决办法

调大nginx.conf中fastcgi参数

fastcgi_connect_timeout 3000;
fastcgi_send_timeout 3000;
fastcgi_read_timeout 1000000000;

此时不会出现502错误了,但是测试benchmark和cpu利用率还是低

[root@li1205-86 ~]# webbench -c 200 -t 60 http://swoole-opencart.shyclouds.com/
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://swoole-opencart.shyclouds.com/
200 clients, running 60 sec.

Speed=317 pages/min, 155975 bytes/sec.
Requests: 317 susceed, 0 failed.

nginx错误日志

cat /usr/local/nginx/logs/error.log | grep error

没有错误

fpm错误日志

vim /usr/local/php/var/log/php-fpm.log

错误

[21-Feb-2019 23:33:56] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 18 total children
[21-Feb-2019 23:33:57] WARNING: [pool www] server reached pm.max_children setting (20), consider raising it
[21-Feb-2019 23:39:44] NOTICE: Finishing ...
[21-Feb-2019 23:39:44] NOTICE: exiting, bye-bye!

调整内核连接数

vim /proc/sys/net/core/somaxconn  # 此处无法修改
128

# 修改成2048
vim /etc/sysctl.conf

net.core.somaxconn = 2048   # 增加这行配置

# 重启
sysctl -p

再次执行测试

webbench -c 100 -t 60 http://swoole-opencart.shyclouds.com/

[root@li1205-86 ~]# webbench -c 200 -t 60 http://swoole-opencart.shyclouds.com/
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://swoole-opencart.shyclouds.com/
200 clients, running 60 sec.

Speed=425 pages/min, 2245100 bytes/sec.
Requests: 425 susceed, 0 failed.
在测试期间,网站可以打开,只是比较慢。

在执行一次

[root@li1205-86 ~]# webbench -c 200 -t 60 http://swoole-opencart.shyclouds.com/    
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://swoole-opencart.shyclouds.com/
200 clients, running 60 sec.

Speed=356 pages/min, 1890314 bytes/sec.
Requests: 356 susceed, 0 failed.

我们取两次测试平均值做基准:(425 + 356) / 2 = 390.5 pages/min



发表我的评论
昵称 (必填)
邮箱 (必填)
网址