openresty performance test analysis report

A, openresty Introduction

1. What is openresty

By rubbing and numerous well-designed Nginx module, OpenResty effectively put Nginx server into a powerful Web application server, based on its core developers can Nginx Nginx C as well as various existing modules using the Lua scripting programming language, It can handle extreme build a high-performance Web applications more than ten thousand concurrent requests.

2. Why Nginx

1, in response to the processing request soon
2, high concurrent connections
3, low memory consumption
4, high reliability:
5, scalability
6, hot deployment
7, the free license BSD

3, openresty architecture model

Nginx uses a master-worker model, a master process to manage multiple worker processes, basic event processing are placed in woker, master responsible for some global initialization, and the management of the worker. In OpenResty each woker a LuaVM use, when the request is assigned to woker, the coroutine will create a (coroutine) in this LuaVM. Data isolation between the coroutine, each having a separate coroutine global variables _G.

. Coroutine PS and similar threads in the multithreaded: has its own stack, its local variables, its own instruction pointer, however, and other programs to share information coroutine global variables. The main and coroutine different threads in that: in the case of multiple processors, multiple threads conceptually run multiple threads simultaneously, and coroutine coroutine is done by switching the code, any time there is only one program running coroutine . And this running coroutine only clear when requested will be suspended pending.

Chart as follows:

 
Architecture Model

OpenResty advantage

First, we chose to use OpenResty, which is the core of Nginx plus many third-party modules, the biggest bright spot is the default Lua integrated development environment, make Nginx as a Web Server to use.

Nginx by means of event-driven model and non-blocking IO, can achieve high-performance Web applications.

And OpenResty provides a number of components such as Mysql, Redis, Memcached, and so on, so that developers on Nginx Web applications more convenient and simple. Currently in Jingdong, such as real-time price spike, dynamic service, single product page, list page so using Nginx + Lua architecture, other companies such as Taobao, where the network and so on.

Two, openresty performance comparison Legend

1. Scenario 1:

Pressure test description:
1, the machine
pressure test: three physical machine configuration cpu: 40 nuclear Memory: 31G is
measured machine: a physical machine configuration cpu: 40 nuclear Memory: 31G is measured machines JVM default configuration
2, the test manner
concurrent pressure measurement, pressure measurement for concurrent from low to high

2, the pressure measurement results

FIG performance openresty

 
Performance Chart .png

 

 
Graph .png

tomcat performance chart

 
Performance Chart .png

 

 
Graph .png

3, the pressure measured analysis
from the pressure test results, in the same number of concurrent case scenario, concurrent with the increase in pressure measurement data, openresty the MRT is more stable and
has remained to around 0.35, while the performance tomcat with the number of concurrent increased, rapid decline in performance, openresty the MRT only
tomcat about 1/10.

2. Scenario 2:

Pressure test description:
1, the machine
pressure test: three physical machine configuration cpu: Nuclear Memory 40: 31G is; three cloud host configuration cpu: memory core. 8: 16G
test machine: a physical machine configuration cpu: nuclear memory 40: 31G test machine JVM default configuration
2, the test mode
increases the amount of requests,

2, the pressure measurement results
openresty FIG performance

 
Performance Chart .png

 

 
Graph .png

tomcat

 
Performance Chart .png

 

 
Graph .png

3、压测分析
从对比来看随着机器增多,tomcat的TPS都有所增加,但是tomcat没有openresty增加的明显,同时openresty的MRT依然在1ms以下,比tomcat要小。

3、场景三:

压测介绍:
1、机器
压测机:3台物理机,配置 cpu: 40核 内存: 31G;3台云主机,配置cpu: 8核 内存: 16G
被测机:1台物理机,配置 cpu: 40核 内存: 31G 被测机JVM默认配置
压测结果
1、并发数300的曲线对比

 
openrestyTPS-RT曲线.png

 

 
tomcatTPS-RT曲线.png

2、对比数2000的曲线对比

 

 
openrestyTPS-RT曲线.png
 
tomcatTPS-RT曲线.png

压测分析
从图中可以看出,在压测条件一致的情况下,openresty的TPS曲线更加稳定,稳定性更高

4、场景四:

压测介绍:
1、机器
压测机:3台物理机,配置 cpu: 40核 内存: 31G
被测机:1台物理机,配置 cpu: 40核 内存: 31G 被测机JVM默认配置
2、测试方式
交叉对比

 
性能图.png
 
性能曲线对比.png

压测介绍:
1、机器
压测机:3台物理机,配置 cpu: 40核 内存: 31G;3台云主机,配置cpu: 8核 内存: 16G
被测机:1台物理机,配置 cpu: 40核 内存: 31G
2、测试方式
交叉对比

 
性能图.png

 

 
性能曲线对比.png

5、场景五:

1、内存使用率对比:

 

 
openresty内存使用率.png
 
tomcat内存使用率.png
 
使用率对比图.png

2、CPU占用率的对比

 

 
openrestyCPU使用率.png
 
tomcatCPU使用率.png
 
使用率对比.png

三、openresty性能分析报告总结

1、在并发度比较低的情况下,比如200一下,openresty和tomcat的性能差别不大,openresty的性能主要体现在占用更小的内存,性能更加稳定;
2、在并发量不断增大,请求量不断增大的情况下,openresty的处理能力更快,不但可以占用更小的内存,还可以保持很小的TPS,获取更高的QPS,性能也更加稳定;
3、openresty在内存使用率,CPU占用率等方面性能要更好;

 
 
 

Guess you like

Origin www.cnblogs.com/gxyandwmm/p/11771271.html