Skip to content

feat(k8s): let large workers reserve less memory than their limit - #1280

Open
danielxnj wants to merge 2 commits into
mainfrom
dj/worker-memory-request-percent
Open

danielxnj wants to merge 2 commits into
mainfrom
dj/worker-memory-request-percent

Conversation

@danielxnj

Copy link
Copy Markdown

Problem

A worker pod requests its whole memory limit, but DuckDB's memory_limit is at most 75% of the pod. The rest is headroom that large workers rarely use. The scheduler reserves it anyway, for every large worker and for every headroom placeholder, so nodes run mostly empty.

Evidence from one fleet (7 days, 10-minute peaks):

  • Workers never used more than 74% of a node's allocatable memory.
  • Workers of 120Gi and larger were above 75% of their limit in under 0.3% of samples.
  • 32Gi workers were above 75% of their limit in 17% of samples, so small workers are excluded.

Replaying the same 7 days of pods with a 75% request for large workers needs about 20% fewer node vCPUs.

Change

  • New env DUCKGRES_K8S_WORKER_MEMORY_REQUEST_PERCENT, 75 to 100. Unset means 100: no change in behavior. An invalid value logs a warning and is ignored.
  • It lowers the memory request of workers whose limit is 64Gi or more. The memory limit, the CPU request and limit, the DuckDB memory_limit, the thread count and billing size do not change.
  • The minimum is 75, so the request always covers DuckDB's memory_limit. Only the headroom above it is shared between the workers of a node.
  • workerMemoryHygieneEnv now reads the memory limit instead of the request. Otherwise a lowered request would also lower DUCKGRES_MEMORY_LIMIT and GOMEMLIMIT.
  • Placeholder size follows automatically, because it comes from the requests of real spawns.

Trade-off

  • Below 100, a large worker pod is Burstable instead of Guaranteed. If several large workers on one node use their headroom at the same time, the node can run out of memory and a worker can be killed.
  • docs/design/connection-string-worker-profile.md says Guaranteed QoS MUST be preserved. I changed that to "by default" with this opt-in exception. Please check that the reason for the rule still allows it.

Testing

  • I am an agent.
  • New unit tests: request and limit per size, request always covers DuckDB's memory_limit (1 to 512Gi), memory env follows the limit, placeholder fallback size, env parsing.
  • go test -tags kubernetes ./controlplane/ ./configresolve/ and go vet pass. golangci-lint reports the same issues as before the change.
  • Not run: the end-to-end suite.

Rollback

  • Unset the env. New workers go back to request equal to limit. Running workers keep their spec until they retire.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GepAgyXv5zVvQV5cbnRF8F

Add DUCKGRES_K8S_WORKER_MEMORY_REQUEST_PERCENT (75-100, default 100).
It lowers the memory request of workers of 64Gi or more. The limit and
the DuckDB memory_limit do not change.


Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GepAgyXv5zVvQV5cbnRF8F
@github-actions

Copy link
Copy Markdown

Test Impact Plan

Deterministic summary of how this PR changes tests, CI runners, and coverage-risk signals.

Summary

Area Added Changed Deleted
Test files 0 3 0
E2E/journey files 0 0 0
Workflow files 0 0 0

Signals

  • Test cases: +4 / -0
  • Assertions: +8 / -0
  • Skips or known failures added: 0
  • Workflow continue-on-error added: 0
  • Workflow path filters added: 0
  • Test commands removed from justfile: 0
  • E2E/journey retry lines added: 0

Coverage risk: neutral or increased

No coverage-reduction warnings detected.

The constant is unused without the kubernetes build tag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GepAgyXv5zVvQV5cbnRF8F

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant