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
@@ -2819,6 +2819,13 @@ fn merge_usage_status_code(
#[async_trait]
impl UsageWriteRepository for InMemoryUsageReadRepository {
fn supports_first_byte_usage_fast_path(&self) -> bool {
// The in-memory repository only implements the general merge path. Do not advertise the
// lightweight path, whose metadata contract is backend-specific and would replace a
// pending row's full audit snapshot with a slim first-byte payload.
false
}
async fn upsert(
&self,
usage: UpsertUsageRecord,