将内存请求设置为小于限制的用例是什么? K8s [英] What is the use case of setting memory request less than limit in . K8s

查看:75
本文介绍了将内存请求设置为小于限制的用例是什么? K8s的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解将CPU请求设置为小于限制的用例-如果实例具有可用的CPU,则它允许每个容器中的CPU突发,从而导致最大的CPU利用率. 但是,我真的找不到用内存做同样的用例.大多数应用程序在分配内存后不会释放内存,因此有效地,应用程序将请求最多限制"的内存(其作用与设置request = limit相同).唯一的例外是在已分配了所有内存的实例上运行的容器.我在这方面没有真正的优点,缺点是不确定性较高的行为,很难监控(由于GC繁重,一个容器的延迟比另一个容器高). 我能想到的唯一用例是内存缓存中的阴影,您希望在此处允许内存使用量激增.但是即使在这种情况下,也将冒着其中一个节点表现不佳的风险.

I understand the use case of setting CPU request less than limit - it allows for CPU bursts in each container if the instances has free CPU hence resulting in max CPU utilization. However, I cannot really find the use case for doing the same with memory. Most application don't release memory after allocating it, so effectively applications will request up to 'limit' memory (which has the same effect as setting request = limit). The only exception is containers running on an instance that already has all its memory allocated. I don't really see any pros in this, and the cons are more nondeterministic behaviour that is hard to monitor (one container having higher latencies than the other due to heavy GC). Only use case I can think of is a shaded in memory cache, where you want to allow for a spike in memory usage. But even in this case one would be running the risk of of one of the nodes underperforming.

推荐答案

也许不是真正的答案,而是关于该主题的观点.

Maybe not a real answer, but a point of view on the subject.

与CPU和内存限制的区别是达到限制时发生的事情.如果使用CPU,容器将继续运行,但是CPU使用率受到限制.如果达到内存限制,容器将被杀死并重新启动.

The difference with the limit on CPU and Memory is what happens when the limit is reached. In case of the CPU, the container keeps running but the CPU usage is limited. If memory limit is reached, container gets killed and restarted.

在我的用例中,我经常将内存请求设置为应用程序平均使用的内存量,并且将限制设置为+ 25%.这使我可以避免大部分时间都杀死容器(这很好),但是当然,这会使我面临内存过度分配的问题(这可能是您所提到的问题).

In my use case, I often set the memory request to the amount of memory my application uses on average, and the limit to +25%. This allows me to avoid container killing most of the time (which is good) but of course it exposes me to memory overallocation (and this could be a problem as you mentioned).

这篇关于将内存请求设置为小于限制的用例是什么? K8s的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆