简体   繁体   English

没有 memory 限制的 Kubernetes pod 中 .net GC 的性能

[英]Performance of .net GC in Kubernetes pod without memory limit

I'm checking on a scaling issue and we are suspecting it has something to do with the memory, but after running a load testing on local machine it doesn't seems to have memory leak.我正在检查缩放问题,我们怀疑它与 memory 有关,但在本地机器上运行负载测试后,它似乎没有 memory 泄漏。 We are hosting the .net core application in Kubernetes, with resources setting 800mi request memory without limit.我们在 Kubernetes 中托管 .net 核心应用程序,资源设置 800mi 请求 memory 无限制。 And as per describe from this Article根据这篇文章的描述

The trigger for Garbage collection occurs when, The system has low physical memory and gets notification from OS.垃圾收集的触发发生在,系统物理 memory 低并从操作系统收到通知。

So does that mean GC is unlikely to kick in until my nodes are low on memory if we did not setup memory limit, and it will eventually occupied most of memory in node?那么这是否意味着如果我们没有设置 memory 限制,直到我的节点在 memory 上处于低位之前,GC 不太可能启动,它最终会占用节点中的大部分 memory?

Yes that's exactly what can happen, both with .NET and other pods.是的,这正是 .NET 和其他吊舱可能发生的情况。

Always set memory and CPU limits as this may have impact on other pods or Configure Default Memory Requests and Limits for a Namespace始终设置 memory 和 CPU 限制,因为这可能会影响其他 pod 或为命名空间配置默认 Memory 请求和限制

@Martin is right but I would like to provide some more insight on this topic. @Martin 是对的,但我想就这个话题提供更多见解。

Kubernetes best practices: Resource requests and limits is a very good guide explaining the idea behind these mechanisms with a detailed explanation and examples. Kubernetes 最佳实践:资源请求和限制是一个很好的指南,通过详细的解释和示例来解释这些机制背后的想法。

Also, Managing Resources for Containers will provide you with the official docs regarding:此外, Managing Resources for Containers将为您提供有关以下方面的官方文档:

  • Requests and limits请求和限制

  • Resource types资源类型

  • Resource requests and limits of Pod and Container Pod 和 Container 的资源请求和限制

  • Resource units in Kubernetes Kubernetes 中的资源单元

  • How Pods with resource requests are scheduled如何调度具有资源请求的 Pod

  • How Pods with resource limits are run, etc如何运行具有资源限制的 Pod 等

Bear in mind that it is very important is to have a good strategy when calculating how much resources you would need for each container.请记住,在计算每个容器需要多少资源时,制定一个好的策略非常重要。 Optimally, your pods should be using exactly the amount of resources you requested but that's almost impossible to achieve.理想情况下,您的 pod 应该使用您请求的资源量,但这几乎是不可能实现的。 If the usage is lower than your request, you are wasting resources.如果使用率低于您的要求,那么您就是在浪费资源。 If it's higher, you are risking performance issues.如果它更高,您将面临性能问题的风险。 Consider a 25% margin up and down the request value as a good starting point.将请求值上下 25% 的余量视为一个好的起点。 Regarding limits, achieving a good setting would depend on trying and adjusting.关于限制,实现良好的设置将取决于尝试和调整。 There is no optimal value that would fit everyone as it depends on many factors related to the application itself, the demand model, the tolerance to errors etc.没有适合每个人的最佳值,因为它取决于与应用程序本身相关的许多因素、需求 model、对错误的容忍度等。

And finally, you can use the metrics-server to get the CPU and memory usage of the pods.最后,您可以使用metrics-server获取 pod 的 CPU 和 memory 使用情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM