News for hackers. Stuff that matters.
Re:Kata Containers: Virtual Machines that feel and perform l... by rwmj on Monday July 17, 2023 @11:37AM (#36759512)
I don't have numbers either, but it's a combination of extreme focus on the boot path, and traditional containers now being quite heavyweight to start (especially when run via Kubernetes).

The big problem with Katacontainers is not whether or not they are slightly faster or slower than containers, but the fixed memory allocation which means you must first know and then allocate the maximum amount of memory they might ever need up front. This can practically limit the number of Katacontainers you can run to something much smaller than is possible with ordinary containers, since RAM is the constrained resource on most servers.

Nevertheless, with confidential computing coming along, it's likely that at some point in the future many containers will really be VMs, since current CPUs implement confidential computing on top of existing VM primitives (and that's basically necessary due to the way the guest RAM is encrypted).

Re:Kata Containers: Virtual Machines that feel and perform l... by cogman10 on Monday July 17, 2023 @12:08PM (#36759943)
> but the fixed memory allocation which means you must first know and then allocate the maximum amount of memory they might ever need up front.

Yup, that's always been the big reason to use containers for me. Startup time and runtime performance are nice benefits, but the memory usage is the giant win. Freeing memory in response to the apps need and also not needing extra memory for running the various OS parts and pieces.

The down side is, of course, security. But that was always the case with containers.

Re:Kata Containers: Virtual Machines that feel and perform l... by tracker1 on Monday July 17, 2023 @12:16PM (#36760043)
I think in the longer run, WASM might displace a lot of both in practical terms.
Re:Kata Containers: Virtual Machines that feel and perform l... by ehutch79 on Monday July 17, 2023 @12:21PM (#36760115)
Why would wasm replace containers? If you're going to run a binary why not just compile it for the local system?

We've always had 'compile once, run anywhere' but there's always been caveats and gotchas.

Re:Kata Containers: Virtual Machines that feel and perform l... by bombela on Monday July 17, 2023 @12:34PM (#36760318)
wasm targets the wasm runtime Virtual Machine (ie: a JavaScript VM). Offering fine grained isolation compared to virtualizing the whole operating system.
Re:Kata Containers: Virtual Machines that feel and perform l... by meepmorp on Monday July 17, 2023 @01:07PM (#36760874)
You could say the same thing for anything that targets JVM or CLR, and they're far more mature than any JS runtime.
Re:Kata Containers: Virtual Machines that feel and perform l... by outworlder on Monday July 17, 2023 @04:11PM (#36763387)
Or even Lua, which is trivial to sandbox.
Re:Kata Containers: Virtual Machines that feel and perform l... by skybrian on Monday July 17, 2023 @02:08PM (#36761824)
Something still compiles a WASM binary for the local system. Possibly, being able to optimize the WASM without recompiling it from source might be a win? Not needing separate binaries for ARM and x86 is nice, so it should run on a Mac more easily. Also, it runs on an edge server or in a browser, even on a phone, if you care about that.

I don’t think it will replace Docker files since they let you package up such a wide variety of existing server software and WASM is more limited. But if your software does compile to WASM then maybe you don’t care about that.

I think of WASM more like a plugin format, but I expect there will be a lot of engineering effort put into optimizing it, like happened with V8 for JavaScript. Not all web standards win, but betting against one that’s well-established and has a lot of support seems like a mistake.

Re:Kata Containers: Virtual Machines that feel and perform l... by wongarsu on Monday July 17, 2023 @02:02PM (#36761698)
For serverless (as in AWS-lambda-like) I agree. In that usecase WASM provides a better security barrier than containers, with faster cold-start time (which is really important for the scaling promise of these services).

For the stuff people run on their Kubernetes clusters I have more mixed expectations. Containers are more universal, but I can totally see a microservice architecture running as a lot of WASM runtimes with a handful of containers.

Re:Kata Containers: Virtual Machines that feel and perform l... by cogman10 on Monday July 17, 2023 @09:05PM (#36766433)
Particularly in the case of Amazon lambdas, those are running in VMS already (firecracker). Why wouldn't you skip the VM and use a static binary from rust instead?
Re:Kata Containers: Virtual Machines that feel and perform l... by hodgesrm on Monday July 17, 2023 @01:48PM (#36761492)
> The big problem with Katacontainers is not whether or not they are slightly faster or slower than containers, but the fixed memory allocation which means you must first know and then allocate the maximum amount of memory they might ever need up front.

Conversely the problem with containers is that memory allocation including the OS page cache is not guaranteed. That's bad for a lot of applications, especially databases. It seems Docker has some support for shared page cache but it's not in the Kubernetes pod spec as far as I can see. [0] You would probably need some kind of annotations and a specialized controller to make this work.

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

Re:Kata Containers: Virtual Machines that feel and perform l... by dharmab on Monday July 17, 2023 @09:50PM (#36766764)
In Kubernetes 1.25+ page cache usage accounting is improved thanks to use of cgroupsv2. https://kubernetes.io/docs/concepts/architecture/cgroups/
Re:Kata Containers: Virtual Machines that feel and perform l... by mochomocha on Monday July 17, 2023 @02:17PM (#36761931)
Slightly off topic, but regarding the larger memory footprint of Kata containers, what is your opinion on KSM effectiveness in general for VMs?
Re:Kata Containers: Virtual Machines that feel and perform l... by rwmj on Monday July 17, 2023 @02:34PM (#36762139)
We had a lot of reports of ksm/ksmtuned consuming a lot of CPU and not making a lot of difference. I think it works well for certain workloads, and can be quite pessimal for others. There are also security concerns because you can leak information about (eg) what glibc is being used by another tenant using timing attacks. So you'd probably want to turn it off if multiple tenants can be using a single node.
Re:Kata Containers: Virtual Machines that feel and perform l... by nimish on Monday July 17, 2023 @02:19PM (#36761951)
Kata containers support memory ballooning like most modern VMs: https://en.wikipedia.org/wiki/Memory_ballooning so a fixed allocation isn't needed, reducing over provisioning

https://github.com/kata-containers/kata-containers/blob/d50f... uses virtio-mem

Re:Kata Containers: Virtual Machines that feel and perform l... by rwmj on Monday July 17, 2023 @02:30PM (#36762093)
This isn't a substitute (nor is virtio-mem, the modern equivalent). The problem is the application running in userspace inside the guest cannot request more memory when, for example, it does a mmap or sbrk.
Re:Kata Containers: Virtual Machines that feel and perform l... by nimish on Monday July 17, 2023 @02:37PM (#36762190)
* * *
Re:Kata Containers: Virtual Machines that feel and perform l... by linlinjin on Monday July 17, 2023 @05:38PM (#36764441)
i couldn't understand the comment that "the application running in user space cannot request more memory" - can someone explain whats the point of memorybalooning anywhere if an application cannot signal when the system should actually provision physical memory from the 'baloon'
Re:Kata Containers: Virtual Machines that feel and perform l... by rwmj on Tuesday July 18, 2023 @04:01AM (#36769262)
There isn't a point, that's the problem.
Re:Kata Containers: Virtual Machines that feel and perform l... by Borealid on Tuesday July 18, 2023 @04:26AM (#36769447)
The systems administrator can use ballooning to give more memory to a VM before launching a new application. This avoids the need to shut down the VM to give it a new role.

There is still a benefit to ballooning support even if it's not exposed to userspace within the VM, because VMs aren't always used purely to host a single infinitely-long-lived application without outside intervention.

Re:Kata Containers: Virtual Machines that feel and perform l... by spockz on Monday July 17, 2023 @04:00PM (#36763244)
Which application languages and frameworks support this kind of dynamic memory allocation? For predictability in performance and throughput reasons we benchmark our Java applications on specific cpu and memory constraints and specific heap and memory settings. How would an app in a container suddenly give back ram? A garbage collected application may be able to do that by collecting garbage. Possibly. But others?
Re:Kata Containers: Virtual Machines that feel and perform l... by rwmj on Monday July 17, 2023 @04:28PM (#36763607)
No idea about Java, but any C program will request memory using mmap, and may give it back using munmap. This doesn't work when the program is running inside a VM, but does work for containers (which are basically just regular processes).
Re:Kata Containers: Virtual Machines that feel and perform l... by fragmede on Monday July 17, 2023 @04:59PM (#36763990)
With VM balloning, VMs are also able to claim and release memory to the hypervisor/host OS.
Re:Kata Containers: Virtual Machines that feel and perform l... by rwmj on Tuesday July 18, 2023 @04:00AM (#36769252)
Not driven by the guest application they don't. It's frustrating that I actually work in this area and know what I'm talking about. I worked on Katacontainers back when it was Intel's Clear Containers in the late 2010s. So many people in this thread do not have a clue.
Re:Kata Containers: Virtual Machines that feel and perform l... by spockz on Wednesday July 19, 2023 @12:11AM (#36782040)
How does this work in practice? If the application didn’t need this memory anymore because it is done with the work/data, shouldn’t it already have freed or munmapped it? Is there a signal that can be send to a process to free up and return memory?
Re:Kata Containers: Virtual Machines that feel and perform l... by sitkack on Tuesday July 18, 2023 @06:29AM (#36770231)
Linux supports hot attach ram or the VMM could support memory ballooning. VMs don’t necessarily need to all be backed by physical RAM.