Commit cbc3149
authored
feat: Dynamic channel pool scaling (#194)
* feat: Dynamic channel pool scaling
Provides dynamic scaling functionality which is configured with three parameters:
- minRpcPerChannel -- minimum desired average concurrent calls per channel.
- maxRpcPerChannel -- maximum desired average concurrent calls per channel.
- scaleDownInterval -- how often to check for a possibility to scale down.
When the average number of concurrent calls per channel reaches `maxRpcPerChannel` the pool will create and add a new channel unless already at max size.
Every `scaleDownInterval` a check for downscaling is performed. Based on the maximum total concurrent calls observed since the last check, the desired number of channels is calculated as:
`(max_total_concurrent_calls / minRpcPerChannel)` rounded up.
If the calculated desired number of channels is lower than the current number of channels, the pool will be downscaled to the desired number or min size (whichever is greater).
When downscaling, channels with the oldest connections are selected. Then the selected channels are removed from the pool but are not instructed to shutdown until all calls are completed. In a case when the pool is scaling up and there is a ready channel awaiting calls completion, the channel will be re-used instead of creating a new channel.
* fix format to satisfy the linter
* Add tests for dynamic pool scaling.
* Lint: formatting
* Fix dynamic channel pool test.
* Fix dynamic scaling with affinity issue
* Add comment for shouldScaleUp. Removed unused totalStreams.1 parent 16a7640 commit cbc3149
8 files changed
Lines changed: 1132 additions & 119 deletions
File tree
- grpc-gcp
- src
- main/java/com/google/cloud/grpc
- multiendpoint
- test/java/com/google/cloud/grpc
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | 4 | | |
6 | | - | |
7 | | - | |
| 5 | + | |
| 6 | + | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
| |||
163 | 162 | | |
164 | 163 | | |
165 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
0 commit comments