govern service 基于 redis 的服務治理平臺(服務注冊/發現 & 配置中心)
govern service 是一個輕量級、低成本的服務注冊、服務發現、 配置服務 sdk,通過使用現有基礎設施中的 redis (相信你已經部署了redis),不用給運維部署帶來額外的成本與負擔。
借助于 redis 的高性能, govern service 提供了超高tps&qps (10w+/s jmh 基準測試)。govern service 結合本地進程緩存策略 + redis pubsub,實現實時進程緩存刷新,兼具無與倫比的qps性能、進程緩存與 redis 的實時一致性。
安裝
gradle
kotlin dsl
1
2
3
|
val governversion = "0.9.13"; implementation("me.ahoo.govern:spring-cloud-starter-config:${governversion}") implementation("me.ahoo.govern:spring-cloud-starter-discovery:${governversion}") |
maven
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
<?xml version="1.0" encoding="utf-8"?> <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"> <modelversion>4.0.0</modelversion> <artifactid>demo</artifactid> <properties> <govern.version>0.9.13</govern.version> </properties> <dependencies> <dependency> <groupid>me.ahoo.govern</groupid> <artifactid>spring-cloud-starter-config</artifactid> <version>${govern.version}</version> </dependency> <dependency> <groupid>me.ahoo.govern</groupid> <artifactid>spring-cloud-starter-discovery</artifactid> <version>${govern.version}</version> </dependency> </dependencies> </project> |
bootstrap.yml (spring-cloud-config)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
spring: application: name: ${service.name:govern-rest-api} cloud: govern: namespace: ${govern.namespace:govern-{system}} config: config-id: ${spring.application.name}.yml redis: mode: ${govern.mode:standalone} url: ${govern.redis.uri:redis://localhost:6379} logging: file: name: logs/${spring.application.name}.log |
rest-api server (optional
)
安裝 rest-api server
方式一:下載可執行文件
解壓 rest-api-0.9.13.tar
1
2
3
|
cd rest-api-0.9.13 # 工作目錄: rest-api-0.9.13 bin /rest-api --server.port=8080 --govern.redis.uri=redis: //localhost :6379 |
方式二:docker run
1
2
|
docker pull ahoowang /govern-service :0.9.13 docker run --name govern-service -d -p 8080:8080 --link redis -e govern_redis_uri=redis: //redis :6379 ahoowang /govern-service :0.9.13 |
macbook pro (m1)
請使用 ahoowang/govern-service:0.9.13-armv7
1
2
|
docker pull ahoowang /govern-service :0.9.13-armv7 docker run --name govern-service -d -p 8080:8080 --link redis -e govern_redis_uri=redis: //redis :6379 ahoowang /govern-service :0.9.13-armv7 |
http://localhost:8080/dashboard
dashboard
命名空間管理
配置管理
服務管理
rest-api
http://localhost:8080/swagger-ui/index.html
namespace
/v1/namespaces
get
/v1/namespaces/{namespace}
put
get
/v1/namespaces/current
get
/v1/namespaces/current/{namespace}
put
config
/v1/namespaces/{namespace}/configs
get
/v1/namespaces/{namespace}/configs/{configid}
get
put
delete
/v1/namespaces/{namespace}/configs/{configid}/versions
get
/v1/namespaces/{namespace}/configs/{configid}/versions/{version}
get
/v1/namespaces/{namespace}/configs/{configid}/to/{targetversion}
put
service
/v1/namespaces/{namespace}/services/
get
/v1/namespaces/{namespace}/services/{serviceid}/instances
get
put
/v1/namespaces/{namespace}/services/{serviceid}/instances/{instanceid}
delete
/v1/namespaces/{namespace}/services/{serviceid}/instances/{instanceid}/metadata
put
/v1/namespaces/{namespace}/services/{serviceid}/lb
get
jmh-benchmark
- 基準測試運行環境:筆記本開發機 ( macbook pro (m1) )
- 所有基準測試都在開發筆記本上執行。
- redis 部署環境也在該筆記本開發機上。
configservice
1
|
gradle config:jmh |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
# jmh version: 1.29 # vm version: jdk 11.0.11, openjdk 64-bit server vm, 11.0.11+9-lts # vm invoker: /library/java/javavirtualmachines/zulu-11.jdk/contents/home/bin/java # vm options: -dfile.encoding=utf-8 -djava.io.tmpdir=/users/ahoo/govern-service/config/build/tmp/jmh -duser.country=cn -duser.language=zh -duser.variant # blackhole mode: full + dont-inline hint # warmup: 1 iterations, 10 s each # measurement: 1 iterations, 10 s each # timeout: 10 min per iteration # threads: 50 threads, will synchronize iterations # benchmark mode: throughput, ops/time benchmark mode cnt score error units consistencyredisconfigservicebenchmark.getconfig thrpt 265321650.148 ops/s redisconfigservicebenchmark.getconfig thrpt 106991.476 ops/s redisconfigservicebenchmark.setconfig thrpt 103659.132 ops/s |
servicediscovery
1
|
gradle discovery:jmh |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# jmh version: 1.29 # vm version: jdk 11.0.11, openjdk 64-bit server vm, 11.0.11+9-lts # vm invoker: /library/java/javavirtualmachines/zulu-11.jdk/contents/home/bin/java # vm options: -dfile.encoding=utf-8 -djava.io.tmpdir=/users/ahoo/govern-service/discovery/build/tmp/jmh -duser.country=cn -duser.language=zh -duser.variant # blackhole mode: full + dont-inline hint # warmup: 1 iterations, 10 s each # measurement: 1 iterations, 10 s each # timeout: 10 min per iteration # threads: 50 threads, will synchronize iterations # benchmark mode: throughput, ops/time benchmark mode cnt score error units consistencyredisservicediscoverybenchmark.getinstances thrpt 76894658.867 ops /s consistencyredisservicediscoverybenchmark.getservices thrpt 466036317.472 ops /s redisservicediscoverybenchmark.getinstances thrpt 107778.244 ops /s redisservicediscoverybenchmark.getservices thrpt 106920.412 ops /s redisserviceregistrybenchmark.deregister thrpt 114094.513 ops /s redisserviceregistrybenchmark.register thrpt 109085.694 ops /s redisserviceregistrybenchmark.renew thrpt 127003.104 ops /s |
作者:ahoo wang (阿虎)
github: https://github.com/ahoo-wang/
smartsql(高性能、高生產力,超輕量級的orm!): https://github.com/dotnetcore/smartsql
smartcode(不只是代碼生成器!): https://github.com/dotnetcore/smartcode
govern service 基于 redis 的服務治理平臺(服務注冊/發現 & 配置中心): https://github.com/ahoo-wang/govern-service
govern eventbus 歷經多年生產環境驗證的事件驅動架構框架: https://github.com/ahoo-wang/govern-eventbus
以上就是govern service 基于 redis 的服務治理平臺的詳細內容,更多關于redis 服務治理的資料請關注服務器之家其它相關文章!
原文鏈接:https://www.cnblogs.com/Ahoo-Wang/p/govern-service.html