.net core下,Ocelot网关与Spring Cloud Gateway网关的对比测试
有感于 myzony 发布的 针对 Ocelot 网关的性能测试 ,并且公司下一步也需要对.net和java的应用做一定的整合,于是对Ocelot网关、Spring Cloud Gateway网关做个了对比测试,使用了wrk进行测试
.net core + Spring Cloud Gateway 是使用 steeltoe 工具接入注册中心Spring Cloud Eureka,共Spring Cloud Gateway调用
应用服务器环境 windows server 2008 .net core 2.2 java 1.8
172.16.1.65 部署 Ocelot的.net core接口-6002、Spring Cloud Gateway的spring boot接口-9004、Spring Cloud Gateway的.net core接口-9001
172.16.1.68 部署 Ocelot的.net core接口-6004、Spring Cloud Gateway的spring boot接口-9004、Spring Cloud Gateway的.net core接口-9001
172.16.1.120 部署 Ocelot网关-6000、Spring Cloud Eureka注册中心-7000 + Spring Cloud Gateway网关-8000
测试工具 wrk 参数统一为 -t 50 -c 10000 -d 60s --latency --timeout 3s
测试服务器环境 centos 7.5 172.16.1.144,并根据 wrk的报错修改了最大打开文件数限制
测试结果汇总如下图

可以看出Ocelot的总请求数、QPS比Gateway高不少,而且超时数也少,但是平均响应时间要比Gateway高不少。
总体上来说,两者基本上处于同一水平,对于一般的企业业务系统足够了,因为上面的测试的都没有涉及业务处理,系统瓶颈不应该是在网关。
考虑我们公司的实际情况,倾向使用 .net core+spring cloud gateway,这样大家各自做各自的,只需要做好接入就好了。
测试结果明细
1. 直测.net core接口 QPS: 51305.10
wrk -t -c -d 60s --latency --timeout 3s http://172.16.1.65:9001/user/get
threads and connections
Thread Stats Avg Stdev Max +/- Stdev
Latency .83ms .10ms .00s 90.15%
Req/Sec .04k 495.03 .76k 78.30%
Latency Distribution
% .64ms
% .33ms
% .34ms
% .98s
requests in 1.00m, .96MB read
Socket errors: connect , read , write , timeout
Requests/sec: 51305.10
Transfer/sec: .34MB
2. 直测spring boot 接口 QPS: 45933.02
wrk -t -c -d 60s --latency --timeout 3s http://172.16.1.65:9004/user/get
threads and connections
Thread Stats Avg Stdev Max +/- Stdev
Latency .69ms .08ms .00s 87.63%
Req/Sec .93k 320.20 .28k 69.47%
Latency Distribution
% .25ms
% .19ms
% .66ms
% .10s
requests in 1.00m, .67MB read
Socket errors: connect , read , write , timeout
Requests/sec: 45933.02
Transfer/sec: .70MB
3. .net core 接口(65:6002、68:6004) + ocelot QPS:9068.52
wrk -t -c -d 60s --latency --timeout 3s http://172.16.1.120:6000/api/values/
threads and connections
Thread Stats Avg Stdev Max +/- Stdev
Latency .82ms .67ms .00s 74.12%
Req/Sec 190.05 119.66 .26k 67.26%
Latency Distribution
% .16ms
% .96ms
% .18s
% .69s
requests in 1.00m, .96MB read
Socket errors: connect , read , write , timeout
Non-2xx or 3xx responses:
Requests/sec: 9068.52
Transfer/sec: .51MB
4. spring boot 接口(65:9004、68:9004) + spring cloud gateway QPS:7497.19
wrk -t -c -d 60s --latency --timeout 3s http://172.16.1.120:8000/user-service/user/get
threads and connections
Thread Stats Avg Stdev Max +/- Stdev
Latency .39ms .40ms .98s 68.88%
Req/Sec 220.62 288.26 .25k 92.94%
Latency Distribution
% .92ms
% .53ms
% .77ms
% .96ms
requests in 1.00m, .72MB read
Socket errors: connect , read , write , timeout
Requests/sec: 7497.19
Transfer/sec: .94MB
5. .net core 接口(65:9001、68:9001) + spring cloud gateway QPS:7762.32
wrk -t -c -d 60s --latency --timeout 3s http://172.16.1.120:8000/user-service/user/get
threads and connections
Thread Stats Avg Stdev Max +/- Stdev
Latency .75ms .90ms .98s 74.25%
Req/Sec 211.85 244.15 .78k 93.53%
Latency Distribution
% .13ms
% .84ms
% .64ms
% .74ms
requests in 1.00m, .73MB read
Socket errors: connect , read , write , timeout
Requests/sec: 7762.32
Transfer/sec: .11MB
.net core 所有应用,在Startup中关闭日志
public void ConfigureServices(IServiceCollection services)
{
services.AddLogging(op => op.ClearProviders());
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
}
Ocelot 网关,在Startup中关闭日志,注释掉mvc的注入和使用
public void ConfigureServices(IServiceCollection services)
{
services.AddLogging(op => op.ClearProviders());
services.AddOcelot(Configuration); //services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
} // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseOcelot().Wait(); //app.UseMvc(routes => {
// routes.MapRoute(
// name: "default",
// template: "{controller=Home}/{action=Index}/{id?}");
//}); }
.net core下,Ocelot网关与Spring Cloud Gateway网关的对比测试的更多相关文章
- Spring Cloud gateway 网关服务二 断言、过滤器
微服务当前这么火爆的程度,如果不能学会一种微服务框架技术.怎么能升职加薪,增加简历的筹码?spring cloud 和 Dubbo 需要单独学习.说没有时间?没有精力?要学俩个框架?而Spring C ...
- 网关服务Spring Cloud Gateway(一)
Spring 官方最终还是按捺不住推出了自己的网关组件:Spring Cloud Gateway ,相比之前我们使用的 Zuul(1.x) 它有哪些优势呢?Zuul(1.x) 基于 Servlet,使 ...
- 微服务网关实战——Spring Cloud Gateway
导读 作为Netflix Zuul的替代者,Spring Cloud Gateway是一款非常实用的微服务网关,在Spring Cloud微服务架构体系中发挥非常大的作用.本文对Spring Clou ...
- Spring Cloud gateway 网关四 动态路由
微服务当前这么火爆的程度,如果不能学会一种微服务框架技术.怎么能升职加薪,增加简历的筹码?spring cloud 和 Dubbo 需要单独学习.说没有时间?没有精力?要学俩个框架?而Spring C ...
- Spring Cloud实战 | 第十一篇:Spring Cloud Gateway 网关实现对RESTful接口权限控制和按钮权限控制
一. 前言 hi,大家好,这应该是农历年前的关于开源项目 的最后一篇文章了. 有来商城 是基于 Spring Cloud OAuth2 + Spring Cloud Gateway + JWT实现的统 ...
- 最全面的改造Zuul网关为Spring Cloud Gateway(包含Zuul核心实现和Spring Cloud Gateway核心实现)
前言: 最近开发了Zuul网关的实现和Spring Cloud Gateway实现,对比Spring Cloud Gateway发现后者性能好支持场景也丰富.在高并发或者复杂的分布式下,后者限流和自定 ...
- 微服务架构spring cloud - gateway网关限流
1.算法 在高并发的应用中,限流是一个绕不开的话题.限流可以保障我们的 API 服务对所有用户的可用性,也可以防止网络攻击. 一般开发高并发系统常见的限流有:限制总并发数(比如数据库连接池.线程池). ...
- 从0开始构建你的api网关--Spring Cloud Gateway网关实战及原理解析
API 网关 API 网关出现的原因是微服务架构的出现,不同的微服务一般会有不同的网络地址,而外部客户端可能需要调用多个服务的接口才能完成一个业务需求,如果让客户端直接与各个微服务通信,会有以下的问题 ...
- api网关揭秘--spring cloud gateway源码解析
要想了解spring cloud gateway的源码,要熟悉spring webflux,我的上篇文章介绍了spring webflux. 1.gateway 和zuul对比 I am the au ...
随机推荐
- 推荐一下《聊聊JVM》的专栏
依照惯例新开了一个专栏后要单推一下.推荐一下<聊聊JVM的专栏>,网上关于JVM的文章太多,这个专栏希望能在已有的资料的基础上写出点新意,对一些重要的概念归纳总结,说说自己的观点.理解和实 ...
- Java中字节与对象之间的转换
近期公司里面用到了消息队列,而正如我们知道的是消息队列之间的是通过二进制形式的.以下就分享一下java中字节与对象之间的转换. 主要是用到了ByteArrayOutputStream和ObjectOu ...
- 数学之路-python计算实战(5)-初识numpy以及pypy下执行numpy
N .有用的线性代数.傅里叶变换和随机数生成函数.numpy和稀疏矩阵运算包scipy配合使用更加方便.NumPy(Numeric Python)提供了很多高级的数值编程工具,如:矩阵数据类型.矢量处 ...
- ios开发网络学习九:NSURLSessionDownloadTask实现大文件下载
一:NSURLSessionDownloadTask:实现文件下载:无法监听进度 #import "ViewController.h" @interface ViewControl ...
- ios开发之核心动画四:核心动画-Core Animation--CABasicAnimation基础核心动画
#import "ViewController.h" @interface ViewController () @property (weak, nonatomic) IBOutl ...
- jquery zoom jquery放大镜特效
这是一款非常不错的给图片添加放大镜效果,可以应用在诸如zen cart,magento电子商场之类的开源项目上.如果想看它的效果,你可以直接访问: http://www.mind-projects.i ...
- 【19.46%】【codeforces 551B】ZgukistringZ
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- Chrome源代码结构
首先,开始接触Chrome的童鞋可能有一个疑惑,Chrome和Chromium是同一个东西吗?答案是,Chrome是Google官方的浏览器项目名称,Chromium是Google官方对Chrome开 ...
- Linux删除非空目录
Linux下如何删除非空目录 这个问题很basic,不过还是困扰了我一段时间.(这里主要讨论的是命令行模式下)我本来觉得应该使用命令 rmdir但是发现它无法删除非空的目录.后来发现了原来应该使用 ...
- .NETCore 实现容器化Docker与私有镜像仓库管理
原文:.NETCore 实现容器化Docker与私有镜像仓库管理 一.Docker介绍 Docker是用Go语言编写基于Linux操作系统的一些特性开发的,其提供了操作系统级别的抽象,是一种容器管理技 ...