stability-patterns-knowledge
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseStability Patterns Knowledge Base
稳定性模式知识库
Quick reference for resilience and fault tolerance patterns in PHP applications.
PHP应用中弹性与容错模式的速查参考。
Core Patterns Overview
核心模式概述
┌─────────────────────────────────────────────────────────────────────────────┐
│ STABILITY PATTERNS │
├─────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌────────────────────────────────────────────────────────────────────┐ │
│ │ REQUEST FLOW │ │
│ │ │ │
│ │ Client ──▶ Rate Limiter ──▶ Circuit Breaker ──▶ Service │ │
│ │ │ │ │ │ │ │
│ │ │ Throttle Monitor State Actual │ │
│ │ │ requests Open/Closed work │ │
│ │ │ │ │ │ │ │
│ │ │ ▼ ▼ ▼ │ │
│ │ │ ┌────────┐ ┌────────┐ ┌────────┐ │ │
│ │ │ │Bulkhead│ │ Retry │ │Timeout │ │ │
│ │ │ │Isolate │ │Pattern │ │Control │ │ │
│ │ │ └────────┘ └────────┘ └────────┘ │ │
│ └────────────────────────────────────────────────────────────────────┘ │
│ │
├─────────────────────────────────────────────────────────────────────────────┤
│ Pattern │ Purpose │ Protects Against │
│ ─────────────────┼────────────────────────────┼─────────────────────────── │
│ Rate Limiter │ Throttle request rate │ DDoS, overload, abuse │
│ Circuit Breaker │ Fail fast on failures │ Cascading failures │
│ Retry │ Retry transient failures │ Temporary outages │
│ Bulkhead │ Isolate resources │ Resource exhaustion │
│ Timeout │ Limit wait time │ Slow dependencies │
└─────────────────────────────────────────────────────────────────────────────┘┌─────────────────────────────────────────────────────────────────────────────┐
│ STABILITY PATTERNS │
├─────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌────────────────────────────────────────────────────────────────────┐ │
│ │ REQUEST FLOW │ │
│ │ │ │
│ │ Client ──▶ Rate Limiter ──▶ Circuit Breaker ──▶ Service │ │
│ │ │ │ │ │ │ │
│ │ │ Throttle Monitor State Actual │ │
│ │ │ requests Open/Closed work │ │
│ │ │ │ │ │ │ │
│ │ │ ▼ ▼ ▼ │ │
│ │ │ ┌────────┐ ┌────────┐ ┌────────┐ │ │
│ │ │ │Bulkhead│ │ Retry │ │Timeout │ │ │
│ │ │ │Isolate │ │Pattern │ │Control │ │ │
│ │ │ └────────┘ └────────┘ └────────┘ │ │
│ └────────────────────────────────────────────────────────────────────┘ │
│ │
├─────────────────────────────────────────────────────────────────────────────┤
│ 模式 │ 用途 │ 防护场景 │
│ ─────────────────┼────────────────────────────┼─────────────────────────── │
│ Rate Limiter │ 限制请求速率 │ DDoS攻击、过载、滥用 │
│ Circuit Breaker │ 故障时快速失败 │ 级联故障 │
│ Retry │ 重试瞬时故障 │ 临时服务中断 │
│ Bulkhead │ 隔离资源 │ 资源耗尽 │
│ Timeout │ 限制等待时间 │ 依赖服务响应缓慢 │
└─────────────────────────────────────────────────────────────────────────────┘Pattern Relationships
模式关联关系
┌─────────────────────────────────────────────────────────────────────────────┐
│ PATTERN INTERACTION │
├─────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌────────────────────┐ │
│ │ Rate Limiter │ │
│ │ (Entry Point) │ │
│ └─────────┬──────────┘ │
│ │ │
│ ▼ │
│ ┌────────────────────┐ │
│ │ Bulkhead │ │
│ │ (Resource Limits) │ │
│ └─────────┬──────────┘ │
│ │ │
│ ┌───────────────────────┼───────────────────────┐ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Service A │ │ Service B │ │ Service C │ │
│ │ ┌────────┐ │ │ ┌────────┐ │ │ ┌────────┐ │ │
│ │ │Circuit │ │ │ │Circuit │ │ │ │Circuit │ │ │
│ │ │Breaker │ │ │ │Breaker │ │ │ │Breaker │ │ │
│ │ └───┬────┘ │ │ └───┬────┘ │ │ └───┬────┘ │ │
│ │ │ │ │ │ │ │ │ │ │
│ │ ┌───▼────┐ │ │ ┌───▼────┐ │ │ ┌───▼────┐ │ │
│ │ │ Retry │ │ │ │ Retry │ │ │ │ Retry │ │ │
│ │ │Pattern │ │ │ │Pattern │ │ │ │Pattern │ │ │
│ │ └────────┘ │ │ └────────┘ │ │ └────────┘ │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────┘┌─────────────────────────────────────────────────────────────────────────────┐
│ PATTERN INTERACTION │
├─────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌────────────────────┐ │
│ │ Rate Limiter │ │
│ │ (Entry Point) │ │
│ └─────────┬──────────┘ │
│ │ │
│ ▼ │
│ ┌────────────────────┐ │
│ │ Bulkhead │ │
│ │ (Resource Limits) │ │
│ └─────────┬──────────┘ │
│ │ │
│ ┌───────────────────────┼───────────────────────┐ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Service A │ │ Service B │ │ Service C │ │
│ │ ┌────────┐ │ │ ┌────────┐ │ │ ┌────────┐ │ │
│ │ │Circuit │ │ │ │Circuit │ │ │ │Circuit │ │ │
│ │ │Breaker │ │ │ │Breaker │ │ │ │Breaker │ │ │
│ │ └───┬────┘ │ │ └───┬────┘ │ │ └───┬────┘ │ │
│ │ │ │ │ │ │ │ │ │ │
│ │ ┌───▼────┐ │ │ ┌───▼────┐ │ │ ┌───▼────┐ │ │
│ │ │ Retry │ │ │ │ Retry │ │ │ │ Retry │ │ │
│ │ │Pattern │ │ │ │Pattern │ │ │ │Pattern │ │ │
│ │ └────────┘ │ │ └────────┘ │ │ └────────┘ │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────┘Quick Reference
速查参考
Circuit Breaker States
Circuit Breaker 状态
| State | Behavior | Transitions To |
|---|---|---|
| Closed | Requests pass through, failures counted | Open (on threshold) |
| Open | Requests fail fast, no calls to service | Half-Open (after timeout) |
| Half-Open | Limited requests allowed for testing | Closed (on success) / Open (on failure) |
| 状态 | 行为 | 转换目标 |
|---|---|---|
| Closed | 请求正常通过,统计故障次数 | Open(达到阈值时) |
| Open | 请求快速失败,不调用服务 | Half-Open(超时后) |
| Half-Open | 允许有限请求用于测试 | Closed(成功时)/ Open(失败时) |
Retry Backoff Strategies
Retry 退避策略
| Strategy | Formula | Use Case |
|---|---|---|
| Fixed | | Simple cases, known recovery time |
| Linear | | Gradual increase |
| Exponential | | Unknown recovery, default choice |
| Exponential + Jitter | | High concurrency, prevents thundering herd |
| 策略 | 公式 | 适用场景 |
|---|---|---|
| Fixed | | 简单场景、已知恢复时间 |
| Linear | | 逐步增加延迟 |
| Exponential | | 未知恢复时间、默认选择 |
| Exponential + Jitter | | 高并发场景、防止惊群效应 |
Rate Limiter Algorithms
Rate Limiter 算法
| Algorithm | Precision | Memory | Burst Handling |
|---|---|---|---|
| Token Bucket | Medium | Low | Allows bursts |
| Sliding Window | High | Medium | Smooth limiting |
| Fixed Window | Low | Low | Edge bursts |
| Leaky Bucket | High | Low | No bursts |
| 算法 | 精度 | 内存占用 | 突发流量处理 |
|---|---|---|---|
| Token Bucket | 中等 | 低 | 允许突发流量 |
| Sliding Window | 高 | 中等 | 平滑限流 |
| Fixed Window | 低 | 低 | 边缘突发流量 |
| Leaky Bucket | 高 | 低 | 不允许突发流量 |
Bulkhead Types
Bulkhead 类型
| Type | Isolation | Use Case |
|---|---|---|
| Semaphore | Thread/request count | Single-process apps |
| Thread Pool | Dedicated threads | CPU-bound work |
| Queue-based | Request queue | Async processing |
| Distributed | Redis/shared state | Multi-instance apps |
| 类型 | 隔离方式 | 适用场景 |
|---|---|---|
| Semaphore | 线程/请求数限制 | 单进程应用 |
| Thread Pool | 专用线程隔离 | CPU密集型任务 |
| Queue-based | 请求队列隔离 | 异步处理 |
| Distributed | Redis/共享状态隔离 | 多实例应用 |
PHP Implementation Patterns
PHP 实现示例
Circuit Breaker with PSR Clock
基于PSR Clock的Circuit Breaker
php
<?php
declare(strict_types=1);
namespace Infrastructure\Resilience;
use Psr\Clock\ClockInterface;
final class CircuitBreaker
{
private CircuitState $state = CircuitState::Closed;
private int $failures = 0;
private ?\DateTimeImmutable $openedAt = null;
public function __construct(
private readonly string $name,
private readonly int $failureThreshold,
private readonly int $openTimeoutSeconds,
private readonly ClockInterface $clock
) {}
public function execute(callable $operation, ?callable $fallback = null): mixed
{
if (!$this->isAvailable()) {
return $fallback ? $fallback() : throw new CircuitOpenException($this->name);
}
try {
$result = $operation();
$this->recordSuccess();
return $result;
} catch (\Throwable $e) {
$this->recordFailure();
throw $e;
}
}
private function isAvailable(): bool
{
if ($this->state === CircuitState::Closed) return true;
if ($this->state === CircuitState::Open) {
if ($this->hasTimeoutElapsed()) {
$this->state = CircuitState::HalfOpen;
return true;
}
return false;
}
return true;
}
}php
<?php
declare(strict_types=1);
namespace Infrastructure\Resilience;
use Psr\Clock\ClockInterface;
final class CircuitBreaker
{
private CircuitState $state = CircuitState::Closed;
private int $failures = 0;
private ?\DateTimeImmutable $openedAt = null;
public function __construct(
private readonly string $name,
private readonly int $failureThreshold,
private readonly int $openTimeoutSeconds,
private readonly ClockInterface $clock
) {}
public function execute(callable $operation, ?callable $fallback = null): mixed
{
if (!$this->isAvailable()) {
return $fallback ? $fallback() : throw new CircuitOpenException($this->name);
}
try {
$result = $operation();
$this->recordSuccess();
return $result;
} catch (\Throwable $e) {
$this->recordFailure();
throw $e;
}
}
private function isAvailable(): bool
{
if ($this->state === CircuitState::Closed) return true;
if ($this->state === CircuitState::Open) {
if ($this->hasTimeoutElapsed()) {
$this->state = CircuitState::HalfOpen;
return true;
}
return false;
}
return true;
}
}Retry with Exponential Backoff
指数退避Retry实现
php
<?php
declare(strict_types=1);
namespace Infrastructure\Resilience;
final readonly class RetryExecutor
{
public function execute(
callable $operation,
int $maxAttempts = 3,
int $baseDelayMs = 100
): mixed {
$attempt = 0;
$lastException = null;
while ($attempt < $maxAttempts) {
try {
return $operation();
} catch (\Throwable $e) {
$lastException = $e;
$attempt++;
if ($attempt < $maxAttempts) {
$delay = $baseDelayMs * (2 ** ($attempt - 1));
$jitter = random_int(0, (int)($delay * 0.3));
usleep(($delay + $jitter) * 1000);
}
}
}
throw $lastException;
}
}php
<?php
declare(strict_types=1);
namespace Infrastructure\Resilience;
final readonly class RetryExecutor
{
public function execute(
callable $operation,
int $maxAttempts = 3,
int $baseDelayMs = 100
): mixed {
$attempt = 0;
$lastException = null;
while ($attempt < $maxAttempts) {
try {
return $operation();
} catch (\Throwable $e) {
$lastException = $e;
$attempt++;
if ($attempt < $maxAttempts) {
$delay = $baseDelayMs * (2 ** ($attempt - 1));
$jitter = random_int(0, (int)($delay * 0.3));
usleep(($delay + $jitter) * 1000);
}
}
}
throw $lastException;
}
}Token Bucket Rate Limiter
Token Bucket Rate Limiter
php
<?php
declare(strict_types=1);
namespace Infrastructure\Resilience;
final class TokenBucketRateLimiter
{
private float $tokens;
private int $lastRefill;
public function __construct(
private readonly int $capacity,
private readonly float $refillRate,
private readonly \Redis $redis,
private readonly string $key
) {
$this->tokens = $capacity;
$this->lastRefill = time();
}
public function attempt(): bool
{
$this->refill();
if ($this->tokens >= 1) {
$this->tokens--;
return true;
}
return false;
}
private function refill(): void
{
$now = time();
$elapsed = $now - $this->lastRefill;
$this->tokens = min(
$this->capacity,
$this->tokens + ($elapsed * $this->refillRate)
);
$this->lastRefill = $now;
}
}php
<?php
declare(strict_types=1);
namespace Infrastructure\Resilience;
final class TokenBucketRateLimiter
{
private float $tokens;
private int $lastRefill;
public function __construct(
private readonly int $capacity,
private readonly float $refillRate,
private readonly \Redis $redis,
private readonly string $key
) {
$this->tokens = $capacity;
$this->lastRefill = time();
}
public function attempt(): bool
{
$this->refill();
if ($this->tokens >= 1) {
$this->tokens--;
return true;
}
return false;
}
private function refill(): void
{
$now = time();
$elapsed = $now - $this->lastRefill;
$this->tokens = min(
$this->capacity,
$this->tokens + ($elapsed * $this->refillRate)
);
$this->lastRefill = $now;
}
}Common Violations Quick Reference
常见违规速查
| Violation | Where to Look | Severity |
|---|---|---|
| No timeout on external calls | HTTP clients, DB queries | Critical |
| Retry without backoff | Retry implementations | Warning |
| No circuit breaker on external services | API clients, adapters | Critical |
| Unbounded connection pools | Database, HTTP pools | Warning |
| No fallback strategy | Circuit breaker usage | Warning |
| Retry non-idempotent operations | Command handlers | Critical |
| Rate limiting only in-memory | Multi-instance apps | Warning |
| No jitter in retry | High-concurrency systems | Warning |
| 违规类型 | 检查位置 | 严重程度 |
|---|---|---|
| 外部调用未设置超时 | HTTP客户端、数据库查询 | 严重 |
| Retry未设置退避 | Retry实现代码 | 警告 |
| 外部服务未使用Circuit Breaker | API客户端、适配器 | 严重 |
| 连接池无边界限制 | 数据库、HTTP连接池 | 警告 |
| 无降级策略 | Circuit Breaker使用处 | 警告 |
| 非幂等操作使用Retry | 命令处理器 | 严重 |
| 仅内存级Rate Limiting | 多实例应用 | 警告 |
| Retry未添加Jitter | 高并发系统 | 警告 |
Detection Patterns
检测模式
bash
undefinedbash
undefinedFind resilience implementations
查找弹性实现代码
Glob: /Resilience//.php
Glob: /CircuitBreaker//.php
Grep: "CircuitBreaker|RateLimiter|Retry" --glob "**/*.php"
Glob: /Resilience//.php
Glob: /CircuitBreaker//.php
Grep: "CircuitBreaker|RateLimiter|Retry" --glob "**/*.php"
Check for proper timeout usage
检查超时使用是否规范
Grep: "CURLOPT_TIMEOUT|timeout|setTimeout" --glob "/Http//*.php"
Grep: "CURLOPT_TIMEOUT|timeout|setTimeout" --glob "/Http//*.php"
Detect retry patterns
检测Retry模式
Grep: "retry|backoff|exponential" --glob "**/*.php"
Grep: "retry|backoff|exponential" --glob "**/*.php"
Find rate limiting
查找Rate Limiting代码
Grep: "RateLimiter|throttle|TokenBucket" --glob "**/*.php"
Grep: "RateLimiter|throttle|TokenBucket" --glob "**/*.php"
Check for bulkhead patterns
检查Bulkhead模式
Grep: "Semaphore|Bulkhead|maxConcurrent" --glob "**/*.php"
Grep: "Semaphore|Bulkhead|maxConcurrent" --glob "**/*.php"
Detect missing patterns
检测缺失的模式
Grep: "->request(|curl_exec|file_get_contents" --glob "/Infrastructure//*.php"
undefinedGrep: "->request(|curl_exec|file_get_contents" --glob "/Infrastructure//*.php"
undefinedConfiguration Guidelines
配置指南
Circuit Breaker Settings
Circuit Breaker 设置
| Service Type | Failure Threshold | Open Timeout | Success Threshold |
|---|---|---|---|
| Critical API | 3-5 | 30-60s | 3-5 |
| Background Job | 5-10 | 60-120s | 2-3 |
| Internal Service | 3-5 | 15-30s | 2-3 |
| Database | 2-3 | 10-20s | 1-2 |
| 服务类型 | 故障阈值 | 打开超时时间 | 成功阈值 |
|---|---|---|---|
| 核心API | 3-5 | 30-60s | 3-5 |
| 后台任务 | 5-10 | 60-120s | 2-3 |
| 内部服务 | 3-5 | 15-30s | 2-3 |
| 数据库 | 2-3 | 10-20s | 1-2 |
Retry Configuration
Retry 配置
| Operation Type | Max Attempts | Base Delay | Max Delay |
|---|---|---|---|
| HTTP API Call | 3 | 100ms | 10s |
| Database Query | 3 | 50ms | 5s |
| Message Queue | 5 | 1s | 60s |
| File Operation | 2 | 10ms | 100ms |
| 操作类型 | 最大重试次数 | 基础延迟 | 最大延迟 |
|---|---|---|---|
| HTTP API调用 | 3 | 100ms | 10s |
| 数据库查询 | 3 | 50ms | 5s |
| 消息队列 | 5 | 1s | 60s |
| 文件操作 | 2 | 10ms | 100ms |
Rate Limiter Settings
Rate Limiter 设置
| Endpoint Type | Rate | Window | Burst |
|---|---|---|---|
| Public API | 100/min | 1 min | 20 |
| Authenticated API | 1000/min | 1 min | 100 |
| Admin API | 10000/min | 1 min | 1000 |
| Webhook | 60/min | 1 min | 10 |
| 端点类型 | 速率 | 时间窗口 | 突发流量 |
|---|---|---|---|
| 公开API | 100次/分钟 | 1分钟 | 20 |
| 已认证API | 1000次/分钟 | 1分钟 | 100 |
| 管理API | 10000次/分钟 | 1分钟 | 1000 |
| Webhook | 60次/分钟 | 1分钟 | 10 |
Integration Points
集成节点
┌─────────────────────────────────────────────────────────────────────────────┐
│ INFRASTRUCTURE LAYER │
├─────────────────────────────────────────────────────────────────────────────┤
│ │
│ src/Infrastructure/ │
│ ├── Resilience/ │
│ │ ├── CircuitBreaker/ │
│ │ │ ├── CircuitBreaker.php │
│ │ │ ├── CircuitBreakerConfig.php │
│ │ │ ├── CircuitBreakerRegistry.php │
│ │ │ └── CircuitState.php │
│ │ ├── Retry/ │
│ │ │ ├── RetryExecutor.php │
│ │ │ ├── RetryPolicy.php │
│ │ │ └── BackoffStrategy.php │
│ │ ├── RateLimiter/ │
│ │ │ ├── RateLimiterInterface.php │
│ │ │ ├── TokenBucketRateLimiter.php │
│ │ │ └── SlidingWindowRateLimiter.php │
│ │ └── Bulkhead/ │
│ │ ├── BulkheadInterface.php │
│ │ ├── SemaphoreBulkhead.php │
│ │ └── BulkheadRegistry.php │
│ │ │
│ ├── Http/ │
│ │ ├── ResilientHttpClient.php ◀── Uses CircuitBreaker + Retry │
│ │ └── Middleware/ │
│ │ └── RateLimitMiddleware.php │
│ │ │
│ └── Payment/ │
│ └── PaymentGatewayAdapter.php ◀── Uses CircuitBreaker + Bulkhead │
│ │
└─────────────────────────────────────────────────────────────────────────────┘┌─────────────────────────────────────────────────────────────────────────────┐
│ INFRASTRUCTURE LAYER │
├─────────────────────────────────────────────────────────────────────────────┤
│ │
│ src/Infrastructure/ │
│ ├── Resilience/ │
│ │ ├── CircuitBreaker/ │
│ │ │ ├── CircuitBreaker.php │
│ │ │ ├── CircuitBreakerConfig.php │
│ │ │ ├── CircuitBreakerRegistry.php │
│ │ │ └── CircuitState.php │
│ │ ├── Retry/ │
│ │ │ ├── RetryExecutor.php │
│ │ │ ├── RetryPolicy.php │
│ │ │ └── BackoffStrategy.php │
│ │ ├── RateLimiter/ │
│ │ │ ├── RateLimiterInterface.php │
│ │ │ ├── TokenBucketRateLimiter.php │
│ │ │ └── SlidingWindowRateLimiter.php │
│ │ └── Bulkhead/ │
│ │ ├── BulkheadInterface.php │
│ │ ├── SemaphoreBulkhead.php │
│ │ └── BulkheadRegistry.php │
│ │ │
│ ├── Http/ │
│ │ ├── ResilientHttpClient.php ◀── 使用CircuitBreaker + Retry │
│ │ └── Middleware/ │
│ │ └── RateLimitMiddleware.php │
│ │ │
│ └── Payment/ │
│ └── PaymentGatewayAdapter.php ◀── 使用CircuitBreaker + Bulkhead │
│ │
└─────────────────────────────────────────────────────────────────────────────┘Advanced Resilience Patterns
高级弹性模式
Backpressure Mechanisms
背压机制
| Strategy | How It Works | PHP Example |
|---|---|---|
| Drop | Discard excess requests | Rate limiter returning 429 |
| Buffer | Queue up to limit | RabbitMQ with max-length |
| Throttle | Slow down producer | Sleep between batch items |
| Reject | Refuse, signal overload | HTTP 503 Service Unavailable |
| Scale | Add more consumers | Auto-scaling worker pool |
| 策略 | 工作原理 | PHP示例 |
|---|---|---|
| Drop | 丢弃超额请求 | Rate Limiter返回429 |
| Buffer | 队列存储至上限 | RabbitMQ设置max-length |
| Throttle | 降低生产者速度 | 批量处理间添加Sleep |
| Reject | 拒绝请求并标记过载 | 返回HTTP 503 Service Unavailable |
| Scale | 添加更多消费者 | 自动扩容工作池 |
Graceful Degradation Levels
优雅降级级别
| Level | Mode | What Happens |
|---|---|---|
| 0 | Full | All features active |
| 1 | Non-Critical Off | Recommendations, analytics disabled |
| 2 | Read-Only | Writes disabled, reads from cache |
| 3 | Static Fallback | Serve cached/static content only |
| 4 | Maintenance | System unavailable page |
| 级别 | 模式 | 行为 |
|---|---|---|
| 0 | 完全模式 | 所有功能启用 |
| 1 | 非核心功能关闭 | 推荐、分析功能禁用 |
| 2 | 只读模式 | 写操作禁用,读取缓存 |
| 3 | 静态降级 | 仅提供缓存/静态内容 |
| 4 | 维护模式 | 显示系统不可用页面 |
Adaptive Retry Jitter Algorithms
自适应Retry Jitter算法
| Algorithm | Formula | Best For |
|---|---|---|
| Full Jitter | | High concurrency |
| Equal Jitter | | Balanced spread |
| Decorrelated | | Sequential retries |
| 算法 | 公式 | 最佳场景 |
|---|---|---|
| Full Jitter | | 高并发场景 |
| Equal Jitter | | 均衡分布 |
| Decorrelated | | 顺序重试 |
Health Check Types
健康检查类型
| Check | Endpoint | Purpose |
|---|---|---|
| Liveness | | Process running (restart if fails) |
| Readiness | | Can accept traffic (remove from LB) |
| Startup | | Has initialized |
| 检查类型 | 端点 | 用途 |
|---|---|---|
| Liveness | | 进程是否运行(失败则重启) |
| Readiness | | 是否可接收流量(失败则从负载均衡移除) |
| Startup | | 是否完成初始化 |
Chaos Engineering Principles
混沌工程原则
| Practice | Description |
|---|---|
| Steady state hypothesis | Define normal behavior metrics |
| Vary real-world events | Inject realistic failures |
| Run in production | Test real behavior |
| Minimize blast radius | Limit failure scope |
| Automate experiments | Continuous chaos testing |
| 实践 | 说明 |
|---|---|
| 稳态假设 | 定义正常行为指标 |
| 模拟真实事件 | 注入真实故障场景 |
| 生产环境测试 | 测试真实行为 |
| 最小影响范围 | 限制故障影响 |
| 自动化实验 | 持续混沌测试 |
References
参考资料
For detailed information, load these reference files:
- — Circuit Breaker implementation details
references/circuit-breaker.md - — Retry strategies and backoff algorithms
references/retry-patterns.md - — Rate limiting algorithms and configurations
references/rate-limiting.md - — Bulkhead isolation patterns
references/bulkhead.md - — Backpressure mechanisms, graceful degradation, adaptive retry with jitter, chaos engineering, health-based routing, fallback strategies
references/advanced-resilience.md
如需详细信息,请查看以下参考文件:
- — Circuit Breaker实现细节
references/circuit-breaker.md - — Retry策略与退避算法
references/retry-patterns.md - — Rate Limiting算法与配置
references/rate-limiting.md - — Bulkhead隔离模式
references/bulkhead.md - — 背压机制、优雅降级、带Jitter的自适应Retry、混沌工程、基于健康状态的路由、降级策略
references/advanced-resilience.md
Assets
资源
- — Structured audit report template
assets/report-template.md
- — 结构化审计报告模板
assets/report-template.md