Soul网关源码学习01
简介
Soul经过不断迭代已经成为高性能、响应式、可扩展的网关一整套解决方案;它参考了Kong、Spring-Cloud-Gateway等优秀的网关,并在此基础上聚合了一系列微服务领域的企业级功能。
-
支持各种语言(http协议),支持 Dubbo,SpringCloud协议。
-
插件化设计思想,插件热插拔,易扩展。
-
灵活的流量筛选,能满足各种流量控制。
-
内置丰富的插件支持,鉴权,限流,熔断,防火墙等等。
-
流量配置动态化,性能极高,网关消耗在 1~2ms。
-
支持集群部署,支持 A/B Test, 蓝绿发布。
准备工作
JDK 1.8+、Maven 3.2.x、Git、MySQL
推荐先Fork到自己的github仓库修改和添加注释可以提交。
git clone https://github.com/dromara/soul.git
编译源码
mvn clean package install -Dmaven.test.skip=true -Dmaven.javadoc.skip=true -Drat.skip=true -Dcheckstyle.skip=true
简单测试
1、启动soul-admin,修改JDBC连接的用户名和密码。
datasource:
url: jdbc:mysql://127.0.0.1:3306/soul?useUnicode=true
username: root
password:
driver-class-name: com.mysql.jdbc.Driver
启动报错
The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
1.语句jdbc:mysql://127.0.0.1:3306/soul 后添加?serverTimezone=UTC
2.更改MySQL的系统时间
set time_zone= '+8:00';
set global time_zone ='+8:00';
启动成功访问:http://127.0.0.1:9095/ 使用admin/123456即可登录。
2、启动soul-bootstrap
3、启动soul-examples的例子
通过examples-http请求 http://127.0.0.1:8188/test/findByUserId?userId=123123通过soul网关请求http://127.0.0.1:9195/http/order/findById?id=123123
1、一般情况下,大型系统做压力测试,10000~50000个并发数,中小型系统做压力测试,5000个并发数比较常见。
2、因为使用单机所以压测30个并发数10秒,通过对比可以发现直接请求和 soul 网关转发请求:吞吐量、平均响应、性能下降比较明显,后续研究是否有参数对soul网关进行调优。