Dubbo-Go provides a built-in Kubernetes HTTP Probe service that supports:
livenessreadinessstartupThe probe service runs on an independent HTTP port and supports:
For a complete runnable example, see:
https://github.com/apache/dubbo-go-samples/tree/main/metrics
| Goal | Description |
|---|---|
| Extensibility | Supports custom health check callbacks |
| Risk Control | Liveness does not bind complex internal logic by default |
| Lifecycle Alignment | Readiness and startup can align with Dubbo lifecycle |
| Independent Port | Isolated from business service port |
When Probe is enabled, it exposes endpoints on:
Port: 22222
The following paths are available:
| Endpoint | Description |
|---|---|
| GET /live | Process liveness check |
| GET /ready | Service readiness check |
| GET /startup | Application startup check |
| Condition | HTTP Status Code |
|---|---|
| All checks pass | 200 |
| Any check fails | 503 |
Dubbo-Go supports both New API (recommended) and Old API (YAML) configuration styles.
ins, err := dubbo.NewInstance(
dubbo.WithMetrics(
metrics.WithProbeEnabled(),
metrics.WithProbePort(22222),
metrics.WithProbeLivenessPath("/live"),
metrics.WithProbeReadinessPath("/ready"),
metrics.WithProbeStartupPath("/startup"),
metrics.WithProbeUseInternalState(true),
),
)
| Option | Description |
|---|---|
| WithProbeEnabled() | Enable Probe |
| WithProbePort(int) | Set Probe HTTP port |
| WithProbeLivenessPath(string) | Set liveness path |
| WithProbeReadinessPath(string) | Set readiness path |
| WithProbeStartupPath(string) | Set startup path |
| WithProbeUseInternalState(bool) | Enable internal lifecycle state check |
metrics:
probe:
enabled: true
port: "22222"
liveness-path: "/live"
readiness-path: "/ready"
startup-path: "/startup"
use-internal-state: true
| Field | Description |
|---|---|
| enabled | Enable probe service |
| port | HTTP port |
| liveness-path | Liveness endpoint path |
| readiness-path | Readiness endpoint path |
| startup-path | Startup endpoint path |
| use-internal-state | Whether to enable internal lifecycle state |
When:
use-internal-state: true
Probe attaches Dubbo internal lifecycle checks.
| Probe Type | Depends On |
|---|---|
| readiness | probe.SetReady(true/false) |
| startup | probe.SetStartupComplete(true/false) |
When Server.Serve() executes successfully:
During graceful shutdown:
If:
use-internal-state: false
The probe result is fully determined by user-registered callbacks.
You can extend probe logic by registering callbacks.
import "dubbo.apache.org/dubbo-go/v3/metrics/probe"
// Liveness example
probe.RegisterLiveness("db", func(ctx context.Context) error {
// check database connectivity
return nil
})
// Readiness example
probe.RegisterReadiness("cache", func(ctx context.Context) error {
// check downstream dependency
return nil
})
// Startup example
probe.RegisterStartup("warmup", func(ctx context.Context) error {
// check warmup completion
return nil
})
Recommended usage:
⚠️ Failure will trigger Pod restart.
May bind to:
Controls whether traffic is routed to the Pod.
Suitable for:
Prevents premature restart during slow initialization.
livenessProbe:
httpGet:
path: /live
port: 22222
initialDelaySeconds: 5
periodSeconds: 5
readinessProbe:
httpGet:
path: /ready
port: 22222
initialDelaySeconds: 5
periodSeconds: 5
startupProbe:
httpGet:
path: /startup
port: 22222
failureThreshold: 30
periodSeconds: 10
Example path:
metrics/probe/
go run ./metrics/probe/go-server/cmd/main.go
watch -n 1 '
for p in live ready startup; do
url="http://127.0.0.1:22222/$p"
body=$(curl -sS --max-time 2 "$url" 2>&1)
code=$(curl -s -o /dev/null --max-time 2 -w "%{http_code}" "$url" 2>/dev/null)
printf "%-8s [%s] %s\n" "$p" "$code" "$body"
done
'
| Phase | /live | /ready | /startup |
|---|---|---|---|
| Just started | 200 | 503 | 503 |
| Warm-up phase | 200 | 503 | 503 |
| Warm-up complete | 200 | 200 | 200 |
| Scenario | Recommendation |
|---|---|
| High availability systems | Keep liveness simple |
| Complex dependencies | Bind readiness to downstream services |
| Long startup time | Always use startup probe |
| Microservice clusters | Enable internal-state |