Why codexSessionAffinityTtlMs is 0 by default? #5718
|
Are there any downsides to enabling it?
What if that account has reached its quota limit? I assume then another account is used instead? Is it correct that enabling this would improve the (upstream) cache-efficiency (and thereby potentially reducing our token cost)? |
Replies: 1 comment
|
Hey @powellnorma! Short answer: it is 0 by default because sticky sessions trade a bit of load-balancing for cache/continuity, and the team left it opt-in rather than forcing that trade-off on everyone. How it works: On quota: you are right, it does NOT get stuck on the exhausted account. Cooldown/rate-limit filtering ( Real downside: it concentrates one conversation's traffic onto a single account, which burns that account's quota window faster than round-robin would (less spreading across your pool during the TTL window). There is also a small extra DB read/write per request to look up and refresh the affinity row. On cache-efficiency: I cannot confirm that part with certainty. The key extraction does accept |
Hey @powellnorma! Short answer: it is 0 by default because sticky sessions trade a bit of load-balancing for cache/continuity, and the team left it opt-in rather than forcing that trade-off on everyone.
How it works:
src/sse/services/auth.ts-- the affinity key comes from a header (x-codex-session-id/x-session-id) or fields in the body (conversation_id,session_id,prompt_cache_key) viaextractSessionAffinityKey(auth.ts:280-305). The TTL is resolved per request (auth.ts:1489-1498) and the actual account pick happens inselectSessionAffinityConnection(auth.ts:728-777), backed by a SQLitekey_valuetable (src/lib/db/sessionAccountAffinity.ts).On quota: you are right, it does NOT get st…