Home

Awesome

CoSky High-performance, low-cost microservice governance platform (Service Discovery and Configuration Service)

License GitHub release Maven Central Codacy Badge codecov Integration Test Status

中文文档

CoSky is a lightweight, low-cost service registration, service discovery, and configuration service SDK. By using Redis in the existing infrastructure (I believe you have already deployed Redis), it doesn’t need to bring extra to the operation and maintenance deployment. Cost and burden. With the high performance of Redis, CoSky provides ultra-high TPS&QPS (100,000+/s JMH Benchmark). CoSky combines the process cache strategy + Redis PubSub to achieve real-time process cache refresh, with unparalleled QPS performance (70,000,000+/s JMH Benchmark) and real-time consistency between process cache and Redis.

Service Discovery

<p align="center"> <img src="./docs/CoSky-Discovery.png" alt="CoSky-Discovery"/> </p>

Configuration

<p align="center"> <img src="./docs/CoSky-Configuration.png" alt="CoSky-Configuration"/> </p>

Examples

Service Consumer --RPC--> Service Provider Examples

Installation

Gradle

Kotlin DSL

    val coskyVersion = "lastVersion";
    implementation("me.ahoo.cosky:spring-cloud-starter-cosky-config:${coskyVersion}")
    implementation("me.ahoo.cosky:spring-cloud-starter-cosky-discovery:${coskyVersion}")
    implementation("org.springframework.cloud:spring-cloud-starter-loadbalancer:3.0.3")

Maven

<?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>
        <cosky.version>lastVersion</cosky.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>me.ahoo.cosky</groupId>
            <artifactId>spring-cloud-starter-cosky-config</artifactId>
            <version>${cosky.version}</version>
        </dependency>
        <dependency>
            <groupId>me.ahoo.cosky</groupId>
            <artifactId>spring-cloud-starter-cosky-discovery</artifactId>
            <version>${cosky.version}</version>
        </dependency>
        <dependency>
          <groupId>org.springframework.cloud</groupId>
          <artifactId>spring-cloud-starter-loadbalancer</artifactId>
          <version>3.0.3</version>
        </dependency>
    </dependencies>

</project>

bootstrap.yaml (Spring-Cloud-Config)

spring:
  application:
    name: ${service.name:cosky}
  data:
    redis:
      url: redis://localhost:6379
  cloud:
    cosky:
      namespace: ${cosky.namespace:cosky-{system}}
      config:
        config-id: ${spring.application.name}.yaml
    service-registry:
      auto-registration:
        enabled: ${cosky.auto-registry:true}
logging:
  file:
    name: logs/${spring.application.name}.log

REST-API Server (Optional)

Installation REST-API Server

Option 1:Download the executable file

Download cosky-server

tar cosky-lastVersion.tar

cd cosky-lastVersion
# Working directory: cosky-lastVersion
bin/cosky --server.port=8080 --spring.data.redis.uri=redis://localhost:6379

Option 2:Run On Docker

docker pull ahoowang/cosky:lastVersion
docker run --name cosky -d -p 8080:8080 --link redis -e SPRING_DATA_REDIS_URL=redis://redis:6379  ahoowang/cosky:lastVersion

Option 3:Run On Kubernetes

apiVersion: apps/v1
kind: Deployment
metadata:
  name: cosky
  labels:
    app: cosky
spec:
  replicas: 1
  selector:
    matchLabels:
      app: cosky
  template:
    metadata:
      labels:
        app: cosky
    spec:
      containers:
        - env:
            - name: SPRING_DATA_REDIS_URL
              value: redis://redis-uri:6379
          image: ahoowang/cosky:lastVersion
          name: cosky
          ports:
            - containerPort: 8080
              protocol: TCP
          resources:
            limits:
              cpu: "1"
              memory: 1280Mi
            requests:
              cpu: 250m
              memory: 1024Mi
          volumeMounts:
            - mountPath: /etc/localtime
              name: volume-localtime
      volumes:
        - hostPath:
            path: /etc/localtime
            type: ""
          name: volume-localtime

---
apiVersion: v1
kind: Service
metadata:
  name: cosky
  labels:
    app: cosky
spec:
  selector:
    app: cosky
  ports:
    - name: rest
      port: 80
      protocol: TCP
      targetPort: 8080

Dashboard

http://localhost:8080/dashboard

<p align="center"> <img src="./docs/dashboard-dashboard.png" alt="CoSky-Dashboard"/> </p>

Service dependent topology

<p align="center"> <img src="./docs/dashboard-topology.png" alt="CoSky-Dashboard-topology"/> </p>

Role-based access control(RBAC)

---------------- ****** CoSky -  init super user:[cosky] password:[6TrmOux4Oj] ****** ----------------

Role Permissions

<p align="center"> <img src="./docs/dashboard-role.png" alt="CoSky-Dashboard-role"/> </p>
Add Role
<p align="center"> <img src="./docs/dashboard-role-add.png" alt="CoSky-Dashboard-role-add"/> </p>

User Management

<p align="center"> <img src="./docs/dashboard-user.png" alt="CoSky-Dashboard-user"/> </p>
Add User
<p align="center"> <img src="./docs/dashboard-user-add.png" alt="CoSky-Dashboard-user-add"/> </p>

Audit Log

<p align="center"> <img src="./docs/dashboard-audit-log.png" alt="CoSky-Dashboard-audit-log"/> </p>

Namespace

<p align="center"> <img src="./docs/dashboard-namespace.png" alt="CoSky-Dashboard-namespace"/> </p>

Config

<p align="center"> <img src="./docs/dashboard-config.png" alt="CoSky-Dashboard-config"/> </p>
Edit configuration
<p align="center"> <img src="./docs/dashboard-config-edit.png" alt="CoSky-Dashboard-config-edit"/> </p>
Rollback configuration
<p align="center"> <img src="./docs/dashboard-config-rollback.png" alt="CoSky-Dashboard-config-rollback"/> </p>
Import configuration from Nacos
<p align="center"> <img src="./docs/dashboard-config-import.gif" alt="CoSky-Dashboard-config-import"/> </p>

Service

<p align="center"> <img src="./docs/dashboard-service.png" alt="CoSky-Dashboard-service"/> </p>
Edit Service Instance
<p align="center"> <img src="./docs/dashboard-service-edit.png" alt="CoSky-Dashboard-service-edit"/> </p>

REST-API

https://ahoo-cosky.apifox.cn/

JMH-Benchmark

ConfigService

gradle cosky-config:jmh
# or
java -jar cosky-config/build/libs/cosky-config-lastVersion-jmh.jar -bm thrpt -t 25 -wi 1 -rf json -f 1
Benchmark                                          Mode  Cnt          Score   Error  Units
ConsistencyRedisConfigServiceBenchmark.getConfig  thrpt       256733987.827          ops/s
RedisConfigServiceBenchmark.getConfig             thrpt          241787.679          ops/s
RedisConfigServiceBenchmark.setConfig             thrpt          140461.112          ops/s

ServiceDiscovery

gradle cosky-discovery:jmh
# or
java -jar cosky-discovery/build/libs/cosky-discovery-lastVersion-jmh.jar -bm thrpt -t 25 -wi 1 -rf json -f 1
Benchmark                                                Mode  Cnt          Score   Error  Units
ConsistencyRedisServiceDiscoveryBenchmark.getInstances  thrpt        76621729.048          ops/s
ConsistencyRedisServiceDiscoveryBenchmark.getServices   thrpt       455760632.346          ops/s
RedisServiceDiscoveryBenchmark.getInstances             thrpt          226909.985          ops/s
RedisServiceDiscoveryBenchmark.getServices              thrpt          304979.150          ops/s
RedisServiceRegistryBenchmark.deregister                thrpt          255305.648          ops/s
RedisServiceRegistryBenchmark.register                  thrpt          110664.160          ops/s
RedisServiceRegistryBenchmark.renew                     thrpt          210960.325          ops/s

CoSky-Mirror (Real-time synchronization of service instance change status)

CoSky-Mirror is like a mirror placed between Nacos and CoSky to build a unified service discovery platform.

<p align="center"> <img src="./docs/CoSky-Mirror.png" alt="CoSky-Mirror"/> </p> <p align="center"> <img src="./docs/CoSky-Mirror-Unified.png" alt="CoSky-Mirror-Unified"/> </p>

Comparison with others

CoSkyEurekaConsulCoreDNSZookeeperNacosApollo
CAPCP+APAPCPCPCPCP+APCP+AP
Health CheckClient BeatClient BeatTCP/HTTP/gRPC/CmdKeep AliveKeep AliveTCP/HTTP/Client BeatClient Beat
Load Balancing StrategyWeight/SelectorRibbonFabioRoundRobinRoundRobinWeight/metadata/RoundRobinRoundRobin
Avalanche ProtectionNYNNNYN
Auto Logoff InstanceSupportSupportNot SupportNot SupportSupportSupportSupport
Access ProtocolHTTP/RedisHTTPHTTP/DNSDNSTCPHTTP/DNSHTTP
Listening SupportSupportSupportSupportNot SupportSupportSupportSupport
Multi-data CenterSupportSupportSupportNot SupportNot SupportSupportSupport
Cross Registry SynchronizationSupportNot SupportSupportNot SupportNot SupportSupportNot Support
SpringCloud IntegrationSupportSupportSupportNot SupportNot SupportSupportSupport
Dubbo IntegrationSupportNot SupportNot SupportNot SupportSupportSupportSupport
K8S IntegrationSupportNot SupportSupportSupportNot SupportSupportNot Support
PersistenceRedisMySqlMySql