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