News for hackers. Stuff that matters.
Re:Tiny Container Challenge: Building a 6kB Containerized HT... by slt2021 on Thursday April 22, 2021 @08:53AM (#26902171)
can anyone explain why you might need to limit memory consumption of your service?

I thought the kernel has virtual memory and if you consume more it will swap some memory and thats it.

Couldnt you just manage memory from inside your app? if its redis, then check the db size and shutdown/cleanup gracefully, and not crash redis with OOM?

Re:Tiny Container Challenge: Building a 6kB Containerized HT... by hardwaresofton on Thursday April 22, 2021 @10:44AM (#26903317)
> can anyone explain why you might need to limit memory consumption of your service?

> I thought the kernel has virtual memory and if you consume more it will swap some memory and thats it.

Well just to make sure the right memory goes to the right places -- if someone uploads a large file and you've made a mistake in your code that tries to hold it all in memory instead of buffering it straight to disk for example, you'd want that process to crash, and not your machine.

Also you generally don't want to swap, so much so that Kubernetes disables it immediately[0]. Not that Google is the only group with the right answer but they seem to think nothing can come of a machine having to swap. Maybe they're right. Even if they're not, A world where one service swaps[1] (I've never done this with docker to try it though) is probably better than one where it uses all the memory and everything swaps.

> Couldnt you just manage memory from inside your app? if its redis, then check the db size and shutdown/cleanup gracefully, and not crash redis with OOM?

You'd be surprised -- some languages just don't have a way to very easily get feedback from GC[2]. It's also something that I don't think most people think about, messing with the -XmXx<setting>s in Java is definitely year 2/3/4 java development for most people.

[0]: https://github.com/kubernetes/kubernetes/issues/53533

[1]: https://docs.docker.com/config/containers/resource_constrain...

[2]: https://github.com/golang/go/issues/29696

Re:Tiny Container Challenge: Building a 6kB Containerized HT... by slt2021 on Thursday April 22, 2021 @11:11AM (#26903634)
Also thank you very much for kubernetes link.

Wow, given how expensive RAM is it is no surprise they will never allow kubernetes work with swap, becausr it directly translates to $$$ for GCP and other cloud providers. Also since everyone loves using Java/Spring/Node and other memory hungry frameworks - it print enormous $ for cloud providers to require users overallocate RAM and disable swap.

or am I just spitballing conspiracy theory here and there is no conflict btw decisions like these and vendors' revenue streams?

Re:Tiny Container Challenge: Building a 6kB Containerized HT... by lanstin on Friday April 23, 2021 @10:23AM (#26915057)
For years, nay decades, the standard for data centers is no swapping. An incident caused by machine went slow due to swapping is almost as embarrassing as one caused by disk filling. Better to orchestrate a restart every night on your leaky code.
Re:Tiny Container Challenge: Building a 6kB Containerized HT... by slt2021 on Thursday April 22, 2021 @11:06AM (#26903580)
I think it is just different thinking: DEV where software is a pet, where I want full control of my memory and take care of it carefully, and dont want anyone shutting down my service violently.

contrast it to Ops mentality of software is a cattle (here is your memory quota and if its OOM, just kill/restart the service and hope next run it wont run OOM)