Commit 4db3c64
committed
chore(spanner): implement dynamic channel pooling and transaction affinity
Adds dynamic channel pooling to the Spanner client, replacing single-channel stubs with an elastic pool of gRPC connections.
- Distributes requests across channels using the Power of Two Choices (P2C) algorithm to avoid hot connections.
- Automatically spins up and warms new channels under heavy load, and quietly drains idle ones when traffic drops.
- Pins multi-step transactions to the same channel so server state remains consistent.
- Supports both static and dynamic configurations, and respects the `SPANNER_NUM_CHANNELS` environment variable.
- Keeps the pool configuration internal (`pub(crate)`) for now while the API and behavior are finalized.1 parent f02b42c commit 4db3c64
22 files changed
Lines changed: 2012 additions & 504 deletions
File tree
- src/spanner/src
- channel_pool
- routing
- server_streaming
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
171 | | - | |
| 171 | + | |
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
| |||
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
234 | | - | |
| 234 | + | |
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
| |||
405 | 405 | | |
406 | 406 | | |
407 | 407 | | |
408 | | - | |
409 | | - | |
| 408 | + | |
| 409 | + | |
410 | 410 | | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
| 411 | + | |
| 412 | + | |
417 | 413 | | |
418 | 414 | | |
419 | 415 | | |
| |||
428 | 424 | | |
429 | 425 | | |
430 | 426 | | |
431 | | - | |
432 | | - | |
| 427 | + | |
433 | 428 | | |
434 | 429 | | |
435 | 430 | | |
| |||
443 | 438 | | |
444 | 439 | | |
445 | 440 | | |
446 | | - | |
447 | | - | |
| 441 | + | |
| 442 | + | |
448 | 443 | | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
| 444 | + | |
455 | 445 | | |
456 | 446 | | |
457 | 447 | | |
| |||
466 | 456 | | |
467 | 457 | | |
468 | 458 | | |
469 | | - | |
470 | | - | |
| 459 | + | |
471 | 460 | | |
472 | 461 | | |
473 | 462 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
212 | | - | |
213 | 212 | | |
214 | 213 | | |
215 | 214 | | |
216 | 215 | | |
217 | | - | |
218 | 216 | | |
219 | 217 | | |
220 | 218 | | |
| |||
230 | 228 | | |
231 | 229 | | |
232 | 230 | | |
233 | | - | |
234 | 231 | | |
235 | 232 | | |
236 | 233 | | |
| |||
291 | 288 | | |
292 | 289 | | |
293 | 290 | | |
294 | | - | |
295 | 291 | | |
296 | 292 | | |
297 | 293 | | |
| |||
317 | 313 | | |
318 | 314 | | |
319 | 315 | | |
320 | | - | |
321 | 316 | | |
322 | 317 | | |
323 | 318 | | |
| |||
436 | 431 | | |
437 | 432 | | |
438 | 433 | | |
439 | | - | |
| 434 | + | |
440 | 435 | | |
441 | 436 | | |
442 | 437 | | |
| |||
540 | 535 | | |
541 | 536 | | |
542 | 537 | | |
543 | | - | |
544 | | - | |
545 | 538 | | |
546 | 539 | | |
547 | 540 | | |
| |||
0 commit comments