
该测试只是简单在同一台机器设备对spring cloud gateway网关和kong网关进行对比,受限于笔者所拥有的资源,此处仅做简单评测。
一、使用spring boot 的auth-service作为服务提供者
该服务提供了一个/health接口,接口返回"OK",运行的地址为:192.168.188.108:8174
二、使用kong 网关代理该服务
2.1、创建service
curl -i -s -X POST http://localhost:8001/services --data name=auth-service --data url='http://192.168.188.108:8174'
2.2. 给服务绑定route
curl -i -X POST http://localhost:8001/services/auth-service/routes --data 'paths[]=/auth-service' --data name=auth-service_route
2.3、测试通过kong网关来进行访问
[root@localhost ~]# curl -X GET http://192.168.188.101:8000/auth-service/health
ok
2.4、使用upstream来进行负载均衡
- 创建upstream
curl -X POST http://localhost:8001/upstreams --data name=auth_upstream
- 给upstream绑定目标服务
curl -X POST http://localhost:8001/upstreams/auth_upstream/targets --data target='192.168.188.108:8174'
curl -X POST http://localhost:8001/upstreams/auth_upstream/targets --data target='192.168.188.108:8176'
- 更新service指定的url地址
curl -X PATCH http://localhost:8001/services/auth-service --data host='auth_upstream'
三、搭建spring cloud 的gateway网关环境
<?xml version="1.0" encoding="UTF-8"?>
<!--suppress MavenPropertyInParent -->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>api-module-gateways</artifactId>
<groupId>com.api</groupId>
<version>${env.project.version}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>manager-gateway</artifactId>
<packaging>jar</packaging>
<description>后台管理网关</description>
<properties>
<maven.compiler.source>8

最低0.47元/天 解锁文章
1080

被折叠的 条评论
为什么被折叠?



