Table of Content:
- 1. Setup
- 2. Demo Application Introduction
- 3. Springboot/Bookinfo Operating
- 4. Dubbo Operating
- 5. Observability
- 6. FAQ
Execute docker-compose -f clickhouse.yaml -d
to run a clickhouse server.
#clickhouse.yaml
version: "3"
services:
server:
container_name: clickhouse-server
image: yandex/clickhouse-server:21.8.10
user: clickhouse
ports:
- "8123:8123"
- "9000:9000"
- "9009:9009"
ulimits:
nproc: 65535
nofile:
soft: 262144
hard: 262144
Update clickhouse address in logger.json.
Do kustomize build. Skip this if nothing change. First of all, make sure the jq
cli installed.
kustomize build --load-restrictor LoadRestrictionsNone config/repo -o artifacts/pipy-repo.yaml
kustomize build --load-restrictor LoadRestrictionsNone config/springboot -o artifacts/springboot.yaml
kustomize build --load-restrictor LoadRestrictionsNone config/bookinfo -o artifacts/bookinfo.yaml
kustomize build --load-restrictor LoadRestrictionsNone config/dubbo -o artifacts/dubbo.yaml
kubectl apply -f artifacts/pipy-repo.yaml
Make sure pipy-repo pod is up:
kubectl get po -n pipy
NAME READY STATUS RESTARTS AGE
pipy-repo-85b756c885-zv5c9 1/1 Running 0 20s
Init springboot codebase:
pushd scripts/springboot
./init-repo.sh
popd
Init bookinfo codebase:
pushd scripts/bookinfo
./init-repo.sh
popd
Init dubbo codebase
pushd scripts/dubbo
./init-repo.sh
popd
kubectl apply -f artifacts/springboot.yaml
kubectl apply -f artifacts/bookinfo.yaml
kubectl apply -f artifacts/dubbo.yaml
SpringBoot Bookinfo
Istio Bookinfo
Dubbo
Currently, match supports header
, method
and path
. All of them supports regular expression.
- Firefox: show rating
- Others: no rating
Config: router.json
- Firefox: show blacking rating
- Chrome: show red rating
- Others: no rating
Config: router.json
Implemented in service provider side.
- SpringBoot Config: throttle.json
- Bookinfo Config: throttle.json
Sample:
{
"services": {
"samples-bookinfo-review": {
"rateLimit": 10
}
}
}
Access review service via gateway and we use wrk to simulate requests, wrk -c5 -t5 -d10s --latency http://localhost:30010/bookinfo-reviews/reviews/2099a055-1e21-46ef-825e-9e0de93554ea
.
Implemented in service provider side.
- SpringBoot Config: circuit-breaker.json
- Bookinfo Config: circuit-breaker.json
{
"services": {
"samples-bookinfo-details": {
"enabled": false
}
},
"response": {
"head": {
"status": 503
},
"message": "service unavailable!"
}
}
Update enabled
to false
and execute curl -is http://localhost:30010/bookinfo-details/details/2099a055-1e21-46ef-825e-9e0de93554ea
. You will get 503 response.
Implemented in service provider side.
{
"services": {
"samples-bookinfo-ratings": {
"white": [],
"black": [
"samples-api-gateway"
]
}
}
}
With config above, you should get 403 forbidden response if attempting to execute curl -i http://localhost:30010/bookinfo-ratings/ratings/2099a055-1e21-46ef-825e-9e0de93554ea
.
Once remove samples-api-gateway
from blacklist, will get 200 response with correct rating data.
There is a HTTP endpoint exposing by Consumer Service which ouputing current date and time.
curl -i --location --request POST '43.129.176.183:30088/hello' --header 'Content-Type: application/json' --header 'Accept: text/plain' --data-raw '{"name": "world"}'
HTTP/1.1 200
Content-Type: text/plain;charset=UTF-8
Content-Length: 80
Date: Sun, 27 Feb 2022 13:23:42 GMT
V1-[hello-service] : Hello, world, Today is (2022-02-27), Time is (13:23:42.739)
Update the config in throttle.json. The current setting of request rating is 10
.
We do request simulating with wrk too. Since the endpoint is one POST one, we need to prepare a Lua script first:
wrk.method = "POST"
wrk.headers["Content-Type"] = "application/json"
wrk.headers["Accept"] = "text/plain"
wrk.body = "{\"name\": \"world\"}"
Store above script in post.lua
and execute command bellow:
wrk -c5 -t5 -d15s --script=/tmp/post.lua --latency http://43.129.176.183:30088/hello
Running 15s test @ http://43.129.176.183:30088/hello
5 threads and 5 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 454.12ms 392.86ms 1.06s 33.04%
Req/Sec 5.40 6.29 30.00 94.12%
Latency Distribution
50% 498.63ms
75% 939.13ms
90% 972.75ms
99% 1.05s
165 requests in 15.04s, 31.24KB read
Requests/sec: 10.97
Transfer/sec: 2.08KB
Adjust the limit rate as you hope and run the test below. One more thing to note, keep the option of thread and connection same for wrk.
Go into config circuit-breaker.json, and set value of enable
to true
. Now you enable the circuit breaker for service io.flomesh.demo.dubbo.api.DemoHelloService:sayHello(Ljava/lang/String;)
. You can also find the fallback reponse there.
Now you can try to send a request:
curl -i --location --request POST '43.129.176.183:30088/hello' --header 'Content-Type: application/json' --header 'Accept: text/plain' --data-raw '{"name": "world"}'
HTTP/1.1 200
Content-Type: text/plain;charset=UTF-8
Content-Length: 80
Date: Sun, 27 Feb 2022 13:32:28 GMT
V1-[hello-service] : Hello, world, Today is (2222-02-22), Time is (22:22:22.222)
It does respond the fallback responce instead of current date and time.
The balck/white list feature is same as SpringBoot one. Update the list in config ban.json.
In this demo, we just deployed v1
version applications. So the consumer-service-v2
in black list won't work, let update to consumer-service-v1
and run the commad.
curl -i --location --request POST '43.129.176.183:30088/hello' --header 'Content-Type: application/json' --header 'Accept: text/plain' --data-raw '{"name": "world"}'
HTTP/1.1 500
Content-Length: 0
Date: Sun, 27 Feb 2022 13:31:33 GMT
Connection: close
This setting means that Hello Servie
deny all requet from consumer-service-v1
. And the Consumer Service
responds with HTTP 500, and you will find exception thrown. As best practice, it's better to handle exception for Dubbo RPC. We simplify this with thrown exception directly.
Request and response loggged into Clickhouse.
Implementing with OpenTelemetry. Logged together with req/res log, and stored in Clickhouse.
Extract metrcis from Clickhouse and display via Grafana.
The pipy repo deployed in cluster is exposed as node port 30060
and it's light without repo GUI.
With anther pipy running as repo client, you can access repo via GUI:
pipy http://localhost:30060 --admin-port=6060
Then, open http://localhost:6060
in browser.