6 ms·
OK, so "containers" were invented so every program could have its own special set of operating system packages. This resulted in hugely bloated memory consumpti
by Animats 10y ago
OK, so "containers" were invented so every program could have its own special set of operating system packages. This resulted in hugely bloated memory consumption, of course. Then each package could be run in its own virtual environment for isolation.
But most of the containers held the same operating system packages anyway. So memory de-deduplication was developed to reduce the bloat. Then flaws in memory de-duplication broke the isolation.
There's something very wrong with this attempt to fix the problem by adding more layers.
- gumby 10y agoWhat happened to just using chroot(), namespaces, and copy-on-write?
- gkya 10y agoThey are not new and/or cool enough.
- the8472 10y agoisn't that the OS-part of what containers are doing anyway?
- grundprinzip 10y agoContainers are just namespaces, mount, user, pin, and network namespaces. The reason why chroot is not enough is that you want to allow a different pace of using certain dependencies is different applications. In a way its similar to how Mac OS packages applications as they all ship their own prefix root so to say.
- voidz 10y agos/pin/pid/ namespace - sorry, just correcting this for newcomers.
- eternalban 10y agoI am watching it now but he's talking about VMs ("KVM") and not "containers". As to why we're in this mess, this rather amusing talk by B. Cantrill discusses the history: https://youtu.be/hgN8pCMLI2U https://youtu.be/hgN8pCMLI2U (Linux) Containers are not VMs: https://wiki.archlinux.org/index.php/Linux_Containers https://wiki.archlinux.org/index.php/Linux_Containers
- antoniob 10y agoThanks for the youtube link! Didn't see that one before. Regarding the attacks and how they relate to containers. It's true that two of the attacks were targeting KVM/KSM i.e. VMs. But one attack was entirely inside a process and conceptually the problem also applies to containers. https://openvz.org/Comparison https://openvz.org/Comparison I haven't yet looked at different container implementations but the row 'Page sharing' suggests that there might be some form of memory deduplication. You could probably use KSM under Linux across containers by registering all memory to KSM through madvise() and MADV_MERGEABLE (http://man7.org/linux/man-pages/man2/madvise.2.html http://man7.org/linux/man-pages/man2/madvise.2.html). https://openvz.org/KSM_(kernel_same-page_merging) https://openvz.org/KSM_(kernel_same-page_merging)
- eternalban 10y ago> conceptually the problem also applies to containers. Yep. c.f. BC's talk @ 34:21 "To improve storage efficiency"
- psi-squared 10y ago(disclaimer: I haven't watched the talk yet, this is just branching off of Animats's comment) One thing I wonder, and which I don't know enough about containers to answer myself, is: Let's say I have a bunch of containers which share most of their system packages, but which each have some extra per-container state (possibly packages, possibly just application data). Suppose I decide to build one read-only image for the common data, along with one smaller, read-write overlay per container. As I understand it, when you run multiple copies of a program on a system not using containers, read-only parts (eg, the .text sections of the executable and of any shared libraries) are only loaded into memory once. Would this behaviour carry over to multiple containers using the above setup? If so, that seems like it would accomplish most of the memory usage reduction for this case, without needing explicit memory deduplication. Of course, this won't fit all use cases, but is it a viable option?
- bitwiseand 10y agoAFAIK, this is how docker CoW works. Your read-only parts i.e. base OS / starting point of the image is always shared. As you make changes a per-container R/W layer records those changes. This link explains it well - https://docs.docker.com/engine/userguide/storagedriver/imagesandcontainers/ https://docs.docker.com/engine/userguide/storagedriver/image...
- psi-squared 10y agoOkay, so on reading through that it looks like the answer to my question is "it depends": * On-disk, the layered approach always saves space, as expected * In memory, it depends on which storage backend you use: apparently btrfs can't share page cache entries between containers, while aufs/overlayfs/zfs can - I'm not sure if this is due to btrfs or docker's btrfs backend. From looking at the relevant sources, it looks like (but I could be wrong if I looked in the wrong places) both exec() and dlopen() end up mmap-ing the executable/libraries into the calling process's address space, which should mean they just reuse the page cache entries. So, if I understand correctly, as long as you pick a filesystem which shares page cache entries between containers, then you do indeed only end up with one copy of (the read-only sections of) executables/libraries in memory, no matter how many containers are running them at once. That's good to know!
- deleted 10y ago[deleted]
- mannykannot 10y agoThe law of unintended consequences - in this case, you take a simplified, abstract model (operating system, processes, memory) of what is really happening, and you modify it to produce a different abstract model (the above in containers), and it looks relatively simple and straightforward, but the abstractions blind you to what is really going on, which is far from that. So good luck, humanity, in keeping AI under control, should it be developed.
- Filligree 10y agoIt's fine, it's fine. We'll just program them to never harm humans or, through inaction, allow humans to come to any sort of harm, no matter how minor.
- Animats 10y agoWhat caused this, perhaps, was continuous OS distribution updating. When OS distributions were updated once a year or so, and there was support for one version back, everybody developed to the same target. Once a year you had to update your code, and you had a year to get ready. Containers, and version pinning, are ways to obtain stability in the face of continuous updating.
- bmh100 10y ago> So good luck, humanity, in keeping AI under control, should it be developed. This seems to anthropomorphize AI. Why should we expect AI in general to be difficult to control? AlphaGo, while not a strong AI, seems quite harmless.
- mikeash 10y agoAlphaGo is still dumber than a potted plant, the tiny amount of intelligence it has is just all focused on Go, which is enough to beat the masters at that one specific task. Now imagine you have a system with human-level intelligence and you tell it to beat the masters. Rather than becoming really good at Go, it might discover how to escape its container and sabotage the match, murder its opponents, etc.
- deleted 10y ago[deleted]
- michaelfeathers 10y agoIt's staggering to think about how many layers there are now. It needs an xkcd graphic.