From 08ca6a2a59d81ae93504e259bf3a99c9e419bcbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E6=9D=A5=E5=AE=BE?= Date: Mon, 9 Dec 2019 13:44:16 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E5=A2=9E=E5=8A=A0nacos=E7=9A=84namespace?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/RegistryServiceNacosImpl.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/service/impl/RegistryServiceNacosImpl.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/service/impl/RegistryServiceNacosImpl.java index a7bfced5..fc47b42f 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/service/impl/RegistryServiceNacosImpl.java +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/service/impl/RegistryServiceNacosImpl.java @@ -2,6 +2,7 @@ package com.gitee.sop.adminserver.service.impl; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.alibaba.nacos.api.PropertyKeyConst; import com.alibaba.nacos.api.exception.NacosException; import com.alibaba.nacos.api.naming.NamingFactory; import com.alibaba.nacos.api.naming.NamingService; @@ -18,11 +19,7 @@ import org.springframework.util.CollectionUtils; import javax.annotation.PostConstruct; import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * nacos接口实现, https://nacos.io/zh-cn/docs/open-api.html @@ -36,6 +33,9 @@ public class RegistryServiceNacosImpl implements RegistryService { @Value("${nacos.discovery.server-addr:${registry.nacos-server-addr:}}") private String nacosAddr; + @Value("${nacos.discovery.namespace:${spring.cloud.nacos.discovery.namespace:}}") + private String nacosNamespace; + private NamingService namingService; @PostConstruct @@ -43,7 +43,12 @@ public class RegistryServiceNacosImpl implements RegistryService { if (StringUtils.isBlank(nacosAddr)) { throw new IllegalArgumentException("请在配置文件中指定nacos.discovery.server-addr参数"); } - namingService = NamingFactory.createNamingService(nacosAddr); + Properties nacosProperties = new Properties(); + nacosProperties.put(PropertyKeyConst.SERVER_ADDR, nacosAddr); + if (StringUtils.isNotBlank(nacosNamespace)) { + nacosProperties.put(PropertyKeyConst.NAMESPACE, nacosNamespace); + } + namingService = NamingFactory.createNamingService(nacosProperties); } @Override From d3d53745f980d018551d8f5d578d673c1bc89d8c Mon Sep 17 00:00:00 2001 From: tanghc Date: Tue, 21 Jan 2020 15:02:31 +0800 Subject: [PATCH 2/7] 3.0.0 --- .../test/java/com/gitee/sop/test/AllInOneTest.java | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/sop-test/src/test/java/com/gitee/sop/test/AllInOneTest.java b/sop-test/src/test/java/com/gitee/sop/test/AllInOneTest.java index 70c3d98e..985a2c15 100644 --- a/sop-test/src/test/java/com/gitee/sop/test/AllInOneTest.java +++ b/sop-test/src/test/java/com/gitee/sop/test/AllInOneTest.java @@ -189,18 +189,6 @@ public class AllInOneTest extends TestBase { client.execute(requestBuilder); } - /** - * 演示将接口名版本号跟在url后面,规则:http://host:port/{method}/{version}/ - */ - public void testRestful() { - Client.RequestBuilder requestBuilder = new Client.RequestBuilder() - .url("http://localhost:8081/alipay.story.get/1.0/") - .bizContent(new BizContent().add("name", "name111")) - .httpMethod(HttpTool.HTTPMethod.GET); - - client.execute(requestBuilder); - } - /** * 演示文件上传 */ From 089964af91ee449c1358fbb663a130561ca0f9aa Mon Sep 17 00:00:00 2001 From: tanghc Date: Mon, 3 Feb 2020 10:20:47 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=BE=A4=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5c5afaf2..a7022eb7 100644 --- a/README.md +++ b/README.md @@ -91,4 +91,4 @@ SOP封装了开放平台大部分功能包括:签名验证、统一异常处 ## 沟通交流 -Q群:50212229 +Q群:167643071 From 69cb993f6e90c898c42c3f4ec4691ae00ef31245 Mon Sep 17 00:00:00 2001 From: tanghc Date: Mon, 3 Feb 2020 10:32:27 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=BE=A4=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index a7022eb7..2b2f2e2c 100644 --- a/README.md +++ b/README.md @@ -92,3 +92,5 @@ SOP封装了开放平台大部分功能包括:签名验证、统一异常处 ## 沟通交流 Q群:167643071 + +![SOP2群](https://images.gitee.com/uploads/images/2020/0203/103119_bdf84eb6_332975.png "SOP2群.png") From 1c4ff766dfdefe6559b1c0bf039d518d0038b08a Mon Sep 17 00:00:00 2001 From: tanghc Date: Mon, 3 Feb 2020 10:37:47 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=BE=A4=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/docs/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/docs/README.md b/doc/docs/README.md index f32b1393..af857fe0 100644 --- a/doc/docs/README.md +++ b/doc/docs/README.md @@ -2,4 +2,6 @@ Git地址:[SOP](https://gitee.com/durcframework/SOP) -Q群:50212229 \ No newline at end of file +Q群:167643071 + +![SOP2群](https://images.gitee.com/uploads/images/2020/0203/103119_bdf84eb6_332975.png "SOP2群.png") From e7daa460056908cd64db2812cd0d8c8ed4ccc477 Mon Sep 17 00:00:00 2001 From: tanghc Date: Wed, 5 Feb 2020 10:56:58 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=80=A7=E8=83=BD?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/docs/files/90999_网关性能测试.md | 47 ++++++++++++++++++---- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/doc/docs/files/90999_网关性能测试.md b/doc/docs/files/90999_网关性能测试.md index a262ab66..f5570577 100644 --- a/doc/docs/files/90999_网关性能测试.md +++ b/doc/docs/files/90999_网关性能测试.md @@ -1,13 +1,13 @@ # 网关性能测试 -**测试环境** - > 注意:记得关闭限流功能 +**测试环境** + - 测试工具:[wrk](https://github.com/wg/wrk),[安装教程](https://www.cnblogs.com/quanxiaoha/p/10661650.html) - 服务器:CentOS7(虚拟机,宿主机:macbookpro),内存:2G,CPU:1,核数:2核 - 运行环境:Java8、Mysql-5.7、Nacos-1.1.3 -- 运行参数: +- 网关启动参数: ``` -verbose:gc -XX:+PrintGCDetails -XX:+PrintHeapAtGC -Xloggc:gc-zuul.log \ @@ -15,7 +15,7 @@ -XX:+UseConcMarkSweepGC ``` -- zuul配置: +- zuul配置(仅针对zuul,Spring Cloud Gateway没有做优化配置): ```properties # 不校验时间,这样一个链接可以一直进行测试 @@ -35,8 +35,6 @@ hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=13000 logging.file=sop-gateway.log ``` -以上配置仅针对zuul,Spring Cloud Gateway没有做优化配置 - CentOS允许最大连接数 ``` $ ulimit -n @@ -63,6 +61,21 @@ Requests/sec: 1441.96 Transfer/sec: 406.96KB ``` +结果说明,下同: + +``` + 8 threads and 200 connections (共8个测试线程,200个连接) + (平均值) (标准差) (最大值)(正负一个标准差所占比例) + Thread Stats Avg Stdev Max +/- Stdev + (延迟) + Latency 139.74ms 69.39ms 617.14ms 69.82% + (每秒请求数) + Req/Sec 182.12 55.74 343.00 66.24% + 43391 requests in 30.09s, 11.96MB read (30.09秒内处理了43391个请求,耗费流量11.96MB) +Requests/sec: 1441.96 (QPS 1441.96,即平均每秒处理请求数为1441.96) +Transfer/sec: 406.96KB (平均每秒流量406.96KB) +``` + - Spring Cloud Zuul测试结果 ``` @@ -113,4 +126,24 @@ Transfer/sec: 226.50KB ``` -综上所述,Spring Cloud Gateway在没有优化的情况下,压测表现比zuul好,但zuul的数据表现也不差,但是出现超时现象,总的来说还是Spring Cloud Gateway具有优势。 \ No newline at end of file +综上所述,Spring Cloud Gateway在没有优化的情况下,压测表现比zuul好,但zuul的数据表现也不差,但是出现超时现象,总的来说还是Spring Cloud Gateway具有优势。 + +附启动脚本: + +`restart.sh` + +```bash +echo "Stopping sop-gateway-1.0.0-SNAPSHOT.jar" +pid=`ps -ef | grep sop-gateway-1.0.0-SNAPSHOT.jar | grep -v grep | awk '{print $2}'` +if [ -n "$pid" ] +then + echo "kill -9 的id:" $pid + kill -9 $pid +fi +nohup java -jar -verbose:gc -XX:+PrintGCDetails -XX:+PrintHeapAtGC -Xloggc:gc.log \ + -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m -Xms1024m -Xmx1024m -Xmn256m -Xss256k -XX:SurvivorRatio=8\ + -XX:+UseConcMarkSweepGC sop-gateway-1.0.0-SNAPSHOT.jar\ + --spring.profiles.active=dev --server.port=8081 & + +tail -f nohup.out +``` \ No newline at end of file From aeae182628ba199eea3aa10d1c1db49c81e1b7ab Mon Sep 17 00:00:00 2001 From: tanghc Date: Wed, 5 Feb 2020 10:57:52 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=80=A7=E8=83=BD?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/docs/_sidebar.md | 72 +++++++++---------- ...测试.md => 90001_网关性能测试.md} | 0 2 files changed, 36 insertions(+), 36 deletions(-) rename doc/docs/files/{90999_网关性能测试.md => 90001_网关性能测试.md} (100%) diff --git a/doc/docs/_sidebar.md b/doc/docs/_sidebar.md index c1076802..ad54925b 100644 --- a/doc/docs/_sidebar.md +++ b/doc/docs/_sidebar.md @@ -1,38 +1,38 @@ -* [首页](/?t=1579512230184) +* [首页](/?t=1580871460178) * 开发文档 - * [快速体验](files/10010_快速体验.md?t=1579512230186) - * [项目接入到SOP](files/10011_项目接入到SOP.md?t=1579512230207) - * [新增接口](files/10020_新增接口.md?t=1579512230208) - * [开发流程](files/10021_开发流程.md?t=1579512230208) - * [业务参数校验](files/10030_业务参数校验.md?t=1579512230208) - * [错误处理](files/10040_错误处理.md?t=1579512230208) - * [编写文档](files/10041_编写文档.md?t=1579512230208) - * [接口交互详解](files/10050_接口交互详解.md?t=1579512230208) - * [easyopen支持](files/10070_easyopen支持.md?t=1579512230208) - * [使用签名校验工具](files/10080_使用签名校验工具.md?t=1579512230209) - * [ISV管理](files/10085_ISV管理.md?t=1579512230209) - * [自定义返回结果](files/10087_自定义返回结果.md?t=1579512230209) - * [自定义过滤器](files/10088_自定义过滤器.md?t=1579512230209) - * [自定义校验token](files/10089_自定义校验token.md?t=1579512230209) - * [路由授权](files/10090_路由授权.md?t=1579512230209) - * [接口限流](files/10092_接口限流.md?t=1579512230209) - * [监控日志](files/10093_监控日志.md?t=1579512230209) - * [SDK开发](files/10095_SDK开发.md?t=1579512230210) - * [使用SpringCloudGateway](files/10096_使用SpringCloudGateway.md?t=1579512230210) - * [应用授权](files/10097_应用授权.md?t=1579512230210) - * [提供restful接口](files/10100_提供restful接口.md?t=1579512230210) - * [文件上传](files/10104_文件上传.md?t=1579512230210) - * [配置Sleuth链路追踪](files/10109_配置Sleuth链路追踪.md?t=1579512230210) - * [预发布灰度发布](files/10110_预发布灰度发布.md?t=1579512230211) - * [动态修改请求参数](files/10111_动态修改请求参数.md?t=1579512230211) - * [使用eureka](files/10112_使用eureka.md?t=1579512230211) - * [扩展其它注册中心](files/10113_扩展其它注册中心.md?t=1579512230211) + * [快速体验](files/10010_快速体验.md?t=1580871460179) + * [项目接入到SOP](files/10011_项目接入到SOP.md?t=1580871460202) + * [新增接口](files/10020_新增接口.md?t=1580871460202) + * [开发流程](files/10021_开发流程.md?t=1580871460202) + * [业务参数校验](files/10030_业务参数校验.md?t=1580871460203) + * [错误处理](files/10040_错误处理.md?t=1580871460203) + * [编写文档](files/10041_编写文档.md?t=1580871460203) + * [接口交互详解](files/10050_接口交互详解.md?t=1580871460203) + * [easyopen支持](files/10070_easyopen支持.md?t=1580871460203) + * [使用签名校验工具](files/10080_使用签名校验工具.md?t=1580871460203) + * [ISV管理](files/10085_ISV管理.md?t=1580871460204) + * [自定义返回结果](files/10087_自定义返回结果.md?t=1580871460204) + * [自定义过滤器](files/10088_自定义过滤器.md?t=1580871460204) + * [自定义校验token](files/10089_自定义校验token.md?t=1580871460204) + * [路由授权](files/10090_路由授权.md?t=1580871460204) + * [接口限流](files/10092_接口限流.md?t=1580871460204) + * [监控日志](files/10093_监控日志.md?t=1580871460204) + * [SDK开发](files/10095_SDK开发.md?t=1580871460204) + * [使用SpringCloudGateway](files/10096_使用SpringCloudGateway.md?t=1580871460205) + * [应用授权](files/10097_应用授权.md?t=1580871460205) + * [提供restful接口](files/10100_提供restful接口.md?t=1580871460205) + * [文件上传](files/10104_文件上传.md?t=1580871460205) + * [配置Sleuth链路追踪](files/10109_配置Sleuth链路追踪.md?t=1580871460205) + * [预发布灰度发布](files/10110_预发布灰度发布.md?t=1580871460205) + * [动态修改请求参数](files/10111_动态修改请求参数.md?t=1580871460205) + * [使用eureka](files/10112_使用eureka.md?t=1580871460205) + * [扩展其它注册中心](files/10113_扩展其它注册中心.md?t=1580871460206) * 原理分析 - * [原理分析之@ApiMapping](files/90010_原理分析之@ApiMapping.md?t=1579512230211) - * [原理分析之如何存储路由](files/90011_原理分析之如何存储路由.md?t=1579512230211) - * [原理分析之如何路由](files/90012_原理分析之如何路由.md?t=1579512230211) - * [原理分析之文档归纳](files/90013_原理分析之文档归纳.md?t=1579512230211) - * [原理分析之预发布灰度发布](files/90014_原理分析之预发布灰度发布.md?t=1579512230211) - * [2.x升3.x注意事项](files/90099_2.x升3.x注意事项.md?t=1579512230212) - * [常见问题](files/90100_常见问题.md?t=1579512230212) - * [网关性能测试](files/90999_网关性能测试.md?t=1579512230212) + * [网关性能测试](files/90001_网关性能测试.md?t=1580871460206) + * [原理分析之@ApiMapping](files/90010_原理分析之@ApiMapping.md?t=1580871460206) + * [原理分析之如何存储路由](files/90011_原理分析之如何存储路由.md?t=1580871460206) + * [原理分析之如何路由](files/90012_原理分析之如何路由.md?t=1580871460206) + * [原理分析之文档归纳](files/90013_原理分析之文档归纳.md?t=1580871460207) + * [原理分析之预发布灰度发布](files/90014_原理分析之预发布灰度发布.md?t=1580871460207) + * [2.x升3.x注意事项](files/90099_2.x升3.x注意事项.md?t=1580871460207) + * [常见问题](files/90100_常见问题.md?t=1580871460207) diff --git a/doc/docs/files/90999_网关性能测试.md b/doc/docs/files/90001_网关性能测试.md similarity index 100% rename from doc/docs/files/90999_网关性能测试.md rename to doc/docs/files/90001_网关性能测试.md