feat(phase-4): WS1 — Production Hardening (Redis rate limiting, DB pool, health endpoint, k6)
Rate limiting: - Replace in-memory express-rate-limit with ioredis + rate-limiter-flexible (sliding window) - Graceful fallback to RateLimiterMemory when Redis unreachable - RATE_LIMIT_WINDOW_MS / RATE_LIMIT_MAX_REQUESTS env var config - Retry-After header on 429 responses - agentidp_rate_limit_hits_total Prometheus counter Database pool: - Explicit pg.Pool config via DB_POOL_MAX/MIN/IDLE_TIMEOUT_MS/CONNECTION_TIMEOUT_MS - Defaults: max=20, min=2, idle=30s, conn timeout=5s - agentidp_db_pool_active_connections + agentidp_db_pool_waiting_requests gauges Health endpoint: - GET /health/detailed — per-service status (database, Redis, Vault, OPA) - healthy / degraded (>1000ms) / unreachable classification - HTTP 200 (all healthy) / 207 (any degraded) / 503 (any unreachable) Load tests: - tests/load/ with k6 scenarios for agent registration (100 VUs), token issuance (1000 VUs), credential rotation (50 VUs) - npm run load-test script Tests: 586 passing, zero TypeScript errors Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -12,7 +12,8 @@
|
||||
"test:integration": "jest tests/integration",
|
||||
"db:migrate": "ts-node scripts/migrate.ts",
|
||||
"lint": "eslint src --ext .ts",
|
||||
"format": "prettier --write src/**/*.ts"
|
||||
"format": "prettier --write src/**/*.ts",
|
||||
"load-test": "k6 run tests/load/agent-registration.js && k6 run tests/load/token-issuance.js && k6 run tests/load/credential-rotation.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@open-policy-agent/opa-wasm": "^1.10.0",
|
||||
@@ -23,6 +24,7 @@
|
||||
"dotenv": "^16.4.5",
|
||||
"express": "^4.18.3",
|
||||
"helmet": "^7.1.0",
|
||||
"ioredis": "^5.10.1",
|
||||
"joi": "^17.12.3",
|
||||
"jsonwebtoken": "^9.0.2",
|
||||
"kafkajs": "^2.2.4",
|
||||
@@ -34,6 +36,7 @@
|
||||
"pino": "^8.19.0",
|
||||
"pino-http": "^9.0.0",
|
||||
"prom-client": "^15.1.3",
|
||||
"rate-limiter-flexible": "^5.0.5",
|
||||
"redis": "^4.6.13",
|
||||
"ulid": "^3.0.2",
|
||||
"uuid": "^9.0.1",
|
||||
|
||||
Reference in New Issue
Block a user