【测试所用服务器8核,16G内存】
压测接口:
很简单,从一张表里根据主键随机查询出一条数据【数据库服务器和WEB服务器分开的】。
表数据量大概:910000+条。

这个测试结果很有趣:
tp5.0和3.2性能没有体现出较大的区别,不知道是不是因为测试太片面。相比原始PHP,性能确实下降得厉害。
JAVA的性能和原生PHP比,还差得不少。谁对JAVA很熟悉的能不能说说,是不是我的测试方法有什么没对,或者说太片面。
swoole有点牛逼。

测试:

ab -n 50000 -c 200 http://127.0.0.1:xxxx/xxxx

Concurrency Level: 200
Complete requests: 50000

测试结果:

Server Software: swoole-http-server【swoole服务器+PHP,启动同CPU数量的进程】
Time taken for tests: 17.169 seconds
Requests per second: 2912.31 [#/sec] (mean)
CPU: 40+%

Server Software: wjt-php【Apache/2.4.12+自写的PHP框架,很简单,可等同于原生PHP】

Time taken for tests: 28.582 seconds
Requests per second: 1749.36 [#/sec] (mean)
CPU: 65+%

Server Software: tp3.2【Apache/2.4.12+thinkphp3.2】

Time taken for tests: 238.234 seconds
Time taken for tests: 230.307 seconds
Requests per second: 209.88 [#/sec] (mean)
Requests per second: 217.10 [#/sec] (mean)
CPU: 91% +
MEM: 15858288 used

Server Software: tp3.2【php-fpm7.3+thinkphp3.2】

Time taken for tests: 202.025 seconds
Requests per second: 242.54 [#/sec] (mean)
Requests per second: 242.39 [#/sec] (mean)
CPU: 92% +
MEM: 15959676 used
14371248

Server Software: tp5.0【apache+tinkphp5.0.20】

Time taken for tests: 220.431 seconds
Requests per second: 226.83 [#/sec] (mean)
CPU: 94% +

Server Software: Apache-Coyote/1.1【JAVA】

Time taken for tests: 49.743 seconds
Requests per second: 1005.17 [#/sec] (mean)
CPU: 95% +

附上测试命令:

swoole
/opt/lampp/bin/ab -n 10000 -c 50 'http://127.0.0.1:80098/test/ticket/index?clientId=41&type=ticket&orderId=118'
/opt/lampp/bin/ab -n 50000 -c 200 -k 'http://127.0.0.1:80098/test/ticket/test?clientId=41&type=ticket&orderId=118'
curl 'http://127.0.0.1:80098/test/ticket/test?clientId=41&type=ticket&orderId=118'

/opt/lampp/bin/ab -n 50000 -c 200 -k 'http://127.0.0.1:80098/index.php?m=spike&c=index&a=indexInfo&__clientId=41&__userId=27.10.195.49&__timestamp=15607601030000&__sign=ab5c8d8ce5d8c0713b80084f99b15fa32&id=906'
/opt/lampp/bin/ab -n 50000 -c 200 'http://127.0.0.1:80098/index.php?m=spike&c=index&a=indexInfo&__clientId=41&__userId=27.10.195.49&__timestamp=15607601030000&__sign=ab5c8d8ce5d8c0713b80084f99b15fa32&id=906'
/opt/lampp/bin/ab -n 50000 -c 200 'http://pwx.test.net/proxyToCommonService2/?m=spike&c=index&a=indexInfo&clientId=41&__clientId=41&__userId=27.10.195.49&__timestamp=15604545835783&__sign=54b36c10ba7cf3cc3529b8b570669ce6&id=906&'
curl "http://127.0.0.1:80098/index.php?m=spike&c=index&a=indexInfo&__clientId=41&__userId=27.10.195.49&__timestamp=15607601030000&__sign=ab5c8d8ce5d8c0713b80084f99b15fa32&id=906"


tp3.2 apache:prefork
/opt/lampp/bin/ab -n 10000 -c 50 'http://127.0.0.1:80071/index.php/test/index/test?clientId=41&type=ticket&orderId=118'
/opt/lampp/bin/ab -n 50000 -c 200 -k 'http://127.0.0.1:80071/index.php/test/index/test?clientId=41&type=ticket&orderId=118'


/opt/lampp/bin/ab -n 50000 -c 200 -k 'http://pwx.test.net/?m=spike&c=index&a=indexInfo&id=906&__clientId=41&__userId=27.10.195.49&__timestamp=1560911902&__sign=6e7904e3d8120dc9c6255cd6940f667a&clientId=41'
curl "http://pwx.test.net/?m=spike&c=index&a=indexInfo&id=906&__clientId=41&__userId=27.10.195.49&__timestamp=1560911902&__sign=6e7904e3d8120dc9c6255cd6940f667a&clientId=41"

tp3.2 php-fpm7.3
/opt/lampp/bin/ab -n 10000 -c 50 -k -r 'http://mp2.test.net/index.php?m=test3&a=test&clientId=41&type=ticket&orderId=118'
/opt/lampp/bin/ab -n 50000 -c 200 -k -r 'http://mp2.test/index.php?m=test3&a=test&clientId=41&type=ticket&orderId=118'

wjt-php
/opt/lampp/bin/ab -n 10000 -c 50 -k 'http://127.0.0.1:80077/index.php?m=Test&a=sql&clientId=41&type=ticket&orderId=118'
/opt/lampp/bin/ab -n 50000 -c 200 -k 'http://127.0.0.1:80077/index.php?m=Test&a=sql&clientId=41&type=ticket&orderId=118'
curl 'http://127.0.0.1:80077/index.php?m=Test&a=sql&clientId=41&type=ticket&orderId=118'

tp5
/opt/lampp/bin/ab -n 10000 -c 50 'http://127.0.0.1:80076/index.php/Test/index/index?clientId=41&type=ticket&orderId=118'
/opt/lampp/bin/ab -n 50000 -c 200 -k 'http://127.0.0.1:80076/index.php/Test/index/index?clientId=41&type=ticket&orderId=118'
curl 'http://127.0.0.1:80076/index.php/Test/index/index?clientId=41&type=ticket&orderId=118'

JAVA
/opt/lampp/bin/ab -n 10000 -c 50 'http://127.0.0.1:80082/ticket/test'
/opt/lampp/bin/ab -n 50000 -c 200 'http://127.0.0.1:80082/ticket/test'
/opt/lampp/bin/ab -n 50000 -c 200 -k 'http://127.0.0.1:80082/ticket/test'
curl 'http://127.0.0.1:80082/ticket/test'

02-12 05:55