mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-12-03 06:43:53 +00:00
Objects in a sync.Pool are assumed to be fungible. This is not a good assumption for pools of *bytes.Buffer because a *bytes.Buffer's underlying array grows as needed to accomodate writes. In Kubernetes, apiservers tend to encode "small" objects very frequently and much larger objects (especially large lists) only occasionally. Under steady load, pooled buffers tend to be borrowed frequently enough to prevent them from being released. Over time, each buffer is used to encode a large object and its capacity increases accordingly. The result is that practically all buffers in the pool retain much more capacity than needed to encode most objects. As a basic mitigation for the worst case, buffers with more capacity than the default max request body size are never returned to the pool.