perf(gateway): scale request hot paths for 20k streams

Shard and singleflight hot-path caches, batch and prioritize candidate and usage lifecycle persistence, and extend database and pressure-test instrumentation for 20k concurrent streams.
This commit is contained in:
elky
2026-07-22 02:11:08 +08:00
parent 7756c0913f
commit fc92c4f431
124 changed files with 36325 additions and 3217 deletions
@@ -0,0 +1,5 @@
-- Empty databases do not need a concurrent build: the snapshot runs before
-- traffic starts and executes inside a transaction.
CREATE INDEX IF NOT EXISTS idx_usage_stale_pending_created_request
ON public.usage USING btree (created_at, request_id)
WHERE status IN ('pending', 'streaming');
@@ -12,3 +12,4 @@
150_background_tasks.sql
160_routing_profiles.sql
170_usage_legacy_body_ref_cleanup_index.sql
180_usage_stale_pending_cleanup_index.sql