Commit 8e925c4
fix(streams): cut SSE error-log volume and add Redis pool headroom
The task-event SSE endpoint holds one blocking XREAD connection per
connected client. When concurrent streams exceed the Redis connection
pool size, every client's read fails on each cycle. Combined with
plain-text logging that splits each traceback into one log entry per
line, and a flat 1s retry, a sustained pool stall becomes a
log-ingestion firehose.
Changes:
- Streaming error path: replace the flat 1s retry with capped
exponential backoff (1->2->4->8->16->30s), reset on a healthy read,
so a tight per-client loop can't hammer Redis or flood logs. Full
tracebacks are still logged on every failure (nothing swallowed) with
a failure counter for context; volume is bounded by the backoff and by
single-entry JSON logging below.
- Default to structured JSON logs in all deployed environments
(ENVIRONMENT != "development"). JSON keeps a multi-line traceback as a
single log entry (newlines live inside the quoted exc_info field)
instead of one cluster-log entry per line. Local development keeps
plain text for readable console output. The JSON formatter already
existed but was gated behind Datadog configuration.
- Bump the in-code REDIS_MAX_CONNECTIONS default (50 -> 200) for
peak-concurrency headroom. This is a mitigation, not a fix:
connections still scale 1:1 with clients. The durable fix is a shared
per-pod reader that fans out to in-process queues. Deployed
environments set the real cap via the REDIS_MAX_CONNECTIONS env var.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 8c060f1 commit 8e925c4
3 files changed
Lines changed: 44 additions & 6 deletions
File tree
- agentex/src
- config
- domain/use_cases
- utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
100 | 106 | | |
101 | 107 | | |
102 | 108 | | |
| |||
164 | 170 | | |
165 | 171 | | |
166 | 172 | | |
167 | | - | |
| 173 | + | |
168 | 174 | | |
169 | 175 | | |
170 | 176 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
117 | 122 | | |
118 | 123 | | |
119 | 124 | | |
| |||
133 | 138 | | |
134 | 139 | | |
135 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
136 | 145 | | |
137 | 146 | | |
138 | 147 | | |
| |||
151 | 160 | | |
152 | 161 | | |
153 | 162 | | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
154 | 171 | | |
155 | | - | |
| 172 | + | |
| 173 | + | |
156 | 174 | | |
157 | 175 | | |
158 | 176 | | |
159 | | - | |
160 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
161 | 182 | | |
162 | 183 | | |
163 | 184 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
17 | 28 | | |
18 | 29 | | |
19 | 30 | | |
| |||
134 | 145 | | |
135 | 146 | | |
136 | 147 | | |
137 | | - | |
| 148 | + | |
138 | 149 | | |
139 | 150 | | |
140 | 151 | | |
| |||
0 commit comments