8000 Don't overcommit memory by lllamnyp · Pull Request #913 · cozystack/cozystack · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Don't overcommit memory #913

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 13, 2025
Merged

Don't overcommit memory #913

merged 1 commit into from
May 13, 2025

Conversation

lllamnyp
Copy link
Member
@lllamnyp lllamnyp commented May 5, 2025

This patch recreates the resource presets with a non-burstable memory allocation (request==limit) and without CPU limits. With the new presets the difference between the larger presets became meaningless, so their values were adjusted.

Resolves #912

Summary by CodeRabbit

  • Chores
    • Updated resource presets across all application charts to remove CPU limits, align memory limits with requests, and standardize memory units for consistency.
    • Adjusted CPU and memory request values for larger presets in several applications.
    • Updated chart versions for all affected applications.
    • Refreshed version mappings to reflect latest commit hashes.
    • Added explicit resource configuration for Redis in the dashboard configuration.

8000
Copy link
Contributor
coderabbitai bot commented May 5, 2025

Walkthrough

Resource templates for multiple applications were updated to remove CPU limits and set memory limits equal to memory requests. Memory units were standardized, and some CPU and memory request values were adjusted. Chart versions were incremented for affected applications. The versions map was updated to reflect new commit hashes and HEAD pointers. No changes were made to exported or public entities.

Changes

Files/Groups Change Summary
packages/apps/*/templates/_resources.tpl Removed CPU limits from resource presets, set memory limits equal to memory requests, standardized units, and adjusted some CPU/memory requests. Comments about limits being 50% higher than requests were removed.
packages/apps/*/Chart.yaml Incremented chart versions for all affected applications.
packages/apps/versions_map Updated HEAD placeholders to a specific commit hash and added new HEAD entries for all listed packages.
packages/system/dashboard/values.yaml Added explicit resource requests/limits for redis.master under kubeapps.dashboard.
.pre-commit-config.yaml Added `git diff --color=always

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Helm Chart
    participant Kubernetes

    User->>Helm Chart: Deploy app with resource preset
    Helm Chart->>Kubernetes: Apply resource manifest
    Kubernetes->>Kubernetes: Schedule pod with requests and limits
    Note right of Kubernetes: CPU limits omitted,\nmemory limits = requests
Loading

Assessment against linked issues

Objective Addressed Explanation
Remove CPU limits and set memory limits equal to requests in resource templates (#912)

Poem

In the meadow of YAML, the rabbits convene,
To trim CPU limits, keep memory clean.
No more overcommit, no throttling in sight,
Resource requests now perfectly right.
With charts updated and versions anew,
A hop and a wiggle—this patch is for you!
((\
( -.-)
o_(")(")

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@lllamnyp lllamnyp self-assigned this May 5, 2025
@lllamnyp lllamnyp force-pushed the 912-fix-resource-presets branch 2 times, most recently from 82fc93c to 0164d27 Compare May 12, 2025 11:29
@lllamnyp lllamnyp marked this pull request as ready for review May 12, 2025 11:31
@lllamnyp lllamnyp requested review from kvaps and klinch0 as code owners May 12, 2025 11:31
Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/apps/redis/templates/_resources.tpl (1)

40-41: Standardized 2xlarge preset memory units and removed CPU limits.

This change completes the consistent application of the new resource configuration pattern across all presets. The 8Gi non-burstable memory allocation is appropriate for the largest tier.

Consider documenting the CPU limits removal rationale.

While the changes are sound, it might be helpful to add a comment explaining the architectural decision to remove CPU limits (to prevent throttling) and match memory requests/limits (to prevent OOM kills). This would help future maintainers understand the reasoning behind these configurations.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 653e2bc and 0164d27.

📒 Files selected for processing (13)
  • packages/apps/clickhouse/templates/_resources.tpl (1 hunks)
  • packages/apps/ferretdb/templates/_resources.tpl (1 hunks)
  • packages/apps/http-cache/templates/_resources.tpl (1 hunks)
  • packages/apps/kafka/templates/_resources.tpl (1 hunks)
  • packages/apps/kubernetes/templates/_resources.tpl (1 hunks)
  • packages/apps/mysql/templates/_resources.tpl (1 hunks)
  • packages/apps/nats/templates/_resources.tpl (1 hunks)
  • packages/apps/postgres/templates/_resources.tpl (1 hunks)
  • packages/apps/rabbitmq/templates/_resources.tpl (1 hunks)
  • packages/apps/redis/templates/_resources.tpl (1 hunks)
  • packages/apps/tcp-balancer/templates/_resources.tpl (1 hunks)
  • packages/apps/vpn/templates/_resources.tpl (1 hunks)
  • packages/system/dashboard/values.yaml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build and Test
🔇 Additional comments (29)
packages/apps/mysql/templates/_resources.tpl (1)

17-41: CPU limits removed and memory resources standardized

These changes implement non-burstable memory allocation by setting memory limits equal to requests, remove CPU limits entirely, and standardize on Gi units for larger memory allocations. This aligns with Kubernetes best practices to avoid CPU throttling while maintaining predictable memory allocation.

packages/apps/rabbitmq/templates/_resources.tpl (1)

17-41: Resource configuration correctly updated

The changes to RabbitMQ's resource presets follow the same pattern as the other applications - removing CPU limits, matching memory limits to requests, and standardizing memory units. This consistent approach across all applications will help prevent unexpected throttling and memory overcommitment issues.

packages/apps/tcp-balancer/templates/_resources.tpl (1)

17-41: Resource presets properly aligned with best practices

The TCP balancer resource presets have been updated following the same pattern as other applications. CPU limits are removed to prevent throttling, memory allocations use consistent units, and memory limits match requests exactly to avoid overcommitment.

packages/apps/kubernetes/templates/_resources.tpl (1)

17-41: Resource configuration correctly modified

Kubernetes resource presets have been consistently updated to follow the same pattern as other applications - eliminating CPU limits to prevent throttling, ensuring memory requests and limits match exactly for predictable allocation, and using standardized units for clarity.

packages/apps/clickhouse/templates/_resources.tpl (3)

17-17: Improved resource handling by removing CPU limits

The removal of CPU limits follows Kubernetes best practices and prevents potential CPU throttling. CPU is a compressible resource, and removing limits avoids unexpected performance issues while still maintaining control through requests.

Also applies to: 21-21, 25-25, 29-29, 33-33, 37-37, 41-41


28-29: Better resource scaling with updated CPU requests and standardized memory units

The changes to CPU requests (500m → 500m → 1 → 2 → 4) create a more meaningful differentiation between preset sizes. Converting memory values to Gi units improves readability and consistency.

Also applies to: 32-33, 36-37, 40-41


17-17: Non-burstable memory configuration helps prevent OOM issues

Setting memory limits equal to requests creates a non-burstable configuration, which ensures pods get exactly what they need and prevents unexpected OOM kills due to overcommitment. This is particularly important for database applications like ClickHouse.

Also applies to: 21-21, 25-25, 29-29, 33-33, 37-37, 41-41

packages/apps/ferretdb/templates/_resources.tpl (3)

17-17: Improved resource handling by removing CPU limits

Removing CPU limits follows Kubernetes best practices and prevents potential CPU throttling. This allows FerretDB to use additional CPU when available while still maintaining control through requests.

Also applies to: 21-21, 25-25, 29-29, 33-33, 37-37, 41-41


28-29: Better resource scaling with updated CPU requests and standardized memory units

The changes to CPU requests create a clearer progression between preset sizes (500m → 500m → 1 → 2 → 4), allowing better horizontal scaling decisions. The standardization to Gi units for larger memory values improves consistency.

Also applies to: 32-33, 36-37, 40-41


17-17: Non-burstable memory configuration prevents memory overcommitment

Setting memory limits equal to requests creates predictable memory behavior and prevents the system from overcommitting memory, which is crucial for database workloads like FerretDB that can experience memory spikes.

Also applies to: 21-21, 25-25, 29-29, 33-33, 37-37, 41-41

packages/apps/postgres/templates/_resources.tpl (3)

17-17: Improved resource handling by removing CPU limits

Removing CPU limits aligns with Kubernetes best practices and prevents potential CPU throttling issues. For database workloads like PostgreSQL, this provides better performance when CPU capacity is available.

Also applies to: 21-21, 25-25, 29-29, 33-33, 37-37, 41-41


28-29: Better resource scaling with updated CPU requests and standardized memory units

The updated CPU request progression (500m → 500m → 1 → 2 → 4) creates clearer differentiation between preset sizes. PostgreSQL performance scales well with additional CPU cores, so this progression makes sense for larger workloads.

Also applies to: 32-33, 36-37, 40-41


17-17: Non-burstable memory configuration critical for database stability

Setting memory limits equal to requests is particularly important for PostgreSQL, as it relies on predictable memory behavior for operations like query execution and caching. This non-burstable configuration helps prevent OOM events that could lead to database restarts.

Also applies to: 21-21, 25-25, 29-29, 33-33, 37-37, 41-41

packages/apps/vpn/templates/_resources.tpl (3)

17-17: Improved resource handling by removing CPU limits

Removing CPU limits aligns with Kubernetes best practices and allows the VPN service to utilize additional CPU when available, which can be important for handling encryption/decryption tasks during peak loads.

Also applies to: 21-21, 25-25, 29-29, 33-33, 37-37, 41-41


28-29: Better resource scaling with updated CPU requests and standardized memory units

The updated CPU request progression (500m → 500m → 1 → 2 → 4) provides clearer differentiation between preset sizes, which is helpful for scaling VPN services based on expected concurrent connections.

Also applies to: 32-33, 36-37, 40-41


17-17: Non-burstable memory configuration ensures VPN service stability

Setting memory limits equal to requests creates a non-burstable configuration that prevents memory overcommitment. For VPN services, predictable memory behavior is important to maintain connection state and avoid unexpected disconnections.

Also applies to: 21-21, 25-25, 29-29, 33-33, 37-37, 41-41

packages/apps/kafka/templates/_resources.tpl (2)

17-17: Removed CPU limits from all resource presets

The changes remove CPU limits from all presets, keeping only memory and ephemeral-storage limits. This change aligns with the PR objective of eliminating CPU limits while making memory allocation non-burstable.

This is a good practice in Kubernetes as CPU limits can sometimes cause throttling issues, while keeping them unlimited allows for better CPU utilization when capacity is available.

Also applies to: 21-21, 25-25, 29-29, 33-33, 37-37, 41-41


28-29: Standardized memory units to Gi notation

Changed memory unit representation from "1024Mi" to "1Gi" for better readability, while ensuring memory limits match requests exactly (non-burstable).

packages/apps/http-cache/templates/_resources.tpl (2)

17-17: Removed CPU limits from all resource presets

CPU limits have been removed from all presets while keeping memory and ephemeral-storage limits. This is consistent with the approach taken in other templates and supports the PR objective to prevent overcommitting resources.

Also applies to: 21-21, 25-25, 29-29, 33-33, 37-37, 41-41


28-29: Standardized memory units and made memory non-burstable

Memory units have been standardized to use "1Gi" instead of "1024Mi" for better readability. Memory limits now exactly match memory requests, implementing non-burstable memory allocation.

packages/apps/nats/templates/_resources.tpl (2)

17-17: Removed CPU limits from all resource presets

CPU limits have been removed from all resource presets, which is consistent with the changes in other templates and the PR objective.

Also applies to: 21-21, 25-25, 29-29, 33-33, 37-37, 41-41


32-33: Adjusted CPU requests for larger presets and standardized memory allocation

The CPU requests for larger presets have been increased (large: 1, xlarge: 2, 2xlarge: 4), which provides better differentiation between preset sizes. Memory units are standardized and limits match requests exactly (non-burstable).

Also applies to: 36-37, 40-41

packages/system/dashboard/values.yaml (1)

24-32: Added Redis master resource configuration with non-burstable memory

New configuration added for the Redis master with explicit resource requests and limits:

  • CPU request of 200m (no CPU limit, consistent with other changes)
  • Memory request and limit both set to 256Mi (non-burstable)

This addition makes the dashboard Redis configuration consistent with the resource management approach implemented across other components.

packages/apps/redis/templates/_resources.tpl (6)

17-17: Removed CPU limits in nano preset.

The removal of CPU limits aligns with modern Kubernetes best practices. CPU limits can cause throttling, which often leads to unexpected performance issues, especially in Redis which is sensitive to latency spikes. By removing CPU limits while keeping requests, you allow for CPU bursting during peak loads without throttling.


21-21: Removed CPU limits in micro preset.

This change is consistent with the removal of CPU limits across all presets. For Redis workloads, this is particularly beneficial as it allows better handling of temporary spikes in CPU usage without throttling.


25-25: Removed CPU limits in small preset.

Consistent with the preceding changes. Removing CPU limits for Redis is a good approach as it prevents potential performance degradation due to CPU throttling.


28-29: Increased medium preset memory and removed CPU limits.

The memory increase from 512Mi to 1Gi creates better differentiation between the small and medium tiers. The non-burstable memory allocation (request equals limit) prevents potential OOM issues that can be especially problematic for Redis.


32-33: Standardized large preset memory units and removed CPU limits.

The change to express memory in Gi units improves readability and is more consistent with industry standards for expressing larger memory allocations. This change maintains the logical progression in the resource tier sizes.


36-37: Standardized xlarge preset memory units and removed CPU limits.

Consistent with other presets, using Gi units for larger memory allocations improves readability. The non-burstable memory configuration is particularly important for Redis to ensure predictable performance.

@lllamnyp lllamnyp force-pushed the 912-fix-resource-presets branch 3 times, most recently from 0b2ec36 to d9145d5 Compare May 12, 2025 12:33
This patch recreates the resource presets with a non-burstable memory
allocation (request==limit) and without CPU limits. With the new presets
the difference between the larger presets became meaningless, so their
values were adjusted.

Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
@lllamnyp lllamnyp force-pushed the 912-fix-resource-presets branch from d9145d5 to db34f31 Compare May 12, 2025 12:59
Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
.pre-commit-config.yaml (2)

21-21: Improve hook metadata to reflect diff display

The hook now prints diffs after generation, but neither the name nor the description mentions this behavior. Consider updating them, for example:

name: Run 'make generate' in all app directories and show diffs
description: Execute code generation and display any changes with color highlighting

21-21: Simplify diff command using Git’s no-pager option

Instead of piping git diff --color=always | cat, you can leverage Git’s built-in pager override:

git --no-pager diff --color

This preserves ANSI color codes without spawning an extra cat process.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d9145d5 and db34f31.

📒 Files selected for processing (26)
  • .pre-commit-config.yaml (1 hunks)
  • packages/apps/clickhouse/Chart.yaml (1 hunks)
  • packages/apps/clickhouse/templates/_resources.tpl (1 hunks)
  • packages/apps/ferretdb/Chart.yaml (1 hunks)
  • packages/apps/ferretdb/templates/_resources.tpl (1 hunks)
  • packages/apps/http-cache/Chart.yaml (1 hunks)
  • packages/apps/http-cache/templates/_resources.tpl (1 hunks)
  • packages/apps/kafka/Chart.yaml (1 hunks)
  • packages/apps/kafka/templates/_resources.tpl (1 hunks)
  • packages/apps/kubernetes/templates/_resources.tpl (1 hunks)
  • packages/apps/mysql/Chart.yaml (1 hunks)
  • packages/apps/mysql/templates/_resources.tpl (1 hunks)
  • packages/apps/nats/Chart.yaml (1 hunks)
  • packages/apps/nats/templates/_resources.tpl (1 hunks)
  • packages/apps/postgres/Chart.yaml (1 hunks)
  • packages/apps/postgres/templates/_resources.tpl (1 hunks)
  • packages/apps/rabbitmq/Chart.yaml (1 hunks)
  • packages/apps/rabbitmq/templates/_resources.tpl (1 hunks)
  • packages/apps/redis/Chart.yaml (1 hunks)
  • packages/apps/redis/templates/_resources.tpl (1 hunks)
  • packages/apps/tcp-balancer/Chart.yaml (1 hunks)
  • packages/apps/tcp-balancer/templates/_resources.tpl (1 hunks)
  • packages/apps/versions_map (6 hunks)
  • packages/apps/vpn/Chart.yaml (1 hunks)
  • packages/apps/vpn/templates/_resources.tpl (1 hunks)
  • packages/system/dashboard/values.yaml (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • packages/apps/mysql/templates/_resources.tpl
  • packages/apps/kafka/Chart.yaml
🚧 Files skipped from review as they are similar to previous changes (23)
  • packages/apps/nats/Chart.yaml
  • packages/apps/tcp-balancer/Chart.yaml
  • packages/apps/http-cache/Chart.yaml
  • packages/apps/clickhouse/Chart.yaml
  • packages/apps/redis/Chart.yaml
  • packages/apps/postgres/Chart.yaml
  • packages/apps/mysql/Chart.yaml
  • packages/apps/vpn/Chart.yaml
  • packages/apps/ferretdb/Chart.yaml
  • packages/apps/http-cache/templates/_resources.tpl
  • packages/apps/clickhouse/templates/_resources.tpl
  • packages/apps/ferretdb/templates/_resources.tpl
  • packages/apps/postgres/templates/_resources.tpl
  • packages/apps/redis/templates/_resources.tpl
  • packages/apps/vpn/templates/_resources.tpl
  • packages/apps/rabbitmq/Chart.yaml
  • packages/apps/kafka/templates/_resources.tpl
  • packages/apps/nats/templates/_resources.tpl
  • packages/system/dashboard/values.yaml
  • packages/apps/kubernetes/templates/_resources.tpl
  • packages/apps/rabbitmq/templates/_resources.tpl
  • packages/apps/tcp-balancer/templates/_resources.tpl
  • packages/apps/versions_map
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build and Test

Copy link
Member
@kvaps kvaps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kvaps kvaps merged commit 2c6338a into main May 13, 2025
6 checks passed
@kvaps kvaps deleted the 912-fix-resource-presets branch May 13, 2025 15:19
lllamnyp pushed a commit that referenced this pull request May 20, 2025
This patch recreates the resource presets with a non-burstable memory
allocation (request==limit) and without CPU limits. With the new presets
the difference between the larger presets became meaningless, so their
values were adjusted.

Resolves #912

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Chores**
- Updated resource presets across all application charts to remove CPU
limits, align memory limits with requests, and standardize memory units
for consistency.
- Adjusted CPU and memory request values for larger presets in several
applications.
  - Updated chart versions for all affected applications.
  - Refreshed version mappings to reflect latest commit hashes.
- Added explicit resource configuration for Redis in the dashboard
configuration.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

(cherry picked from commit 2c6338a)
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
@lllamnyp lllamnyp mentioned this pull request May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Resource templates overcommit memory and can throttle CPU
3 participants
0