Four causes
Why does a sandbox cost what it costs?
Four causes explain the largest slowdowns that we measured. We changed three of them with a setting. One of them needs a different machine. Some costs stay after each change. Each cause shows the sandbox where it was largest, then the other sandboxes.
Kata’s shared folder
- What happened
- Kata unpacked node_modules in 11.0 s. A plain container did the same work in 0.20 s.
- Why
- Kata runs the pod in a small VM, but the pod files stay in a folder on the node. Each file operation leaves the VM, goes to a helper program on the node, and comes back. An unpack does many thousands of small file operations. This file path has the name virtio-fs.
- What we changed
- We gave the VM a disk of its own for the container and its volumes. The name of this storage type is a block disk. File operations then stay in the VM.
- Result
- The same unpack took 0.10 s.
- Other sandboxes
- Only Kata with a shared folder has this cause. In the main run, the same unpack was 62× slower in Kata with Cloud Hypervisor and 147× slower in Kata with Dragonball. Kata with Firecracker has no shared folder: 0.7×. gVisor was 7× slower for a different reason. Sysbox and AWS Nitro were the same as a plain container.
- Experiment
- Tuning experiment: all Kata tests with the block disk →
Unpack node_modules for each sandbox →
11.0 s → 0.10 sUnpack node_modules in Kata with QEMU. First with the shared folder, then with a block disk.Tuning run, files on the container’s own disk. Plain container (runc) in the same run: 0.20 s. Thus 54× slower became 0.5×. The Compare page shows 66× for this job: a different run, with files on a mounted volume.
The pod CPU limit counts sandbox work
- What happened
- gVisor unpacked node_modules 3.6× slower than a plain container in a pod with a limit of 1 CPU.
- Why
- Kubernetes counts the work of the sandbox itself in the CPU limit of the pod. The gVisor kernel and the Kata VM use CPU time for each request from your program. When the pod has used its allowance, the node stops the pod until the next period. In one test loop, gVisor was stopped for 27.3 of 41.0 seconds. The plain container was not stopped.
- What we changed
- We gave the sandbox a CPU allowance of its own. The setting is pod overhead in the RuntimeClass.
- Result
- The gVisor unpack went from approximately 3.6× to 1.8×. This change decreases the overhead. It does not remove it.
- Other sandboxes
- Kata with QEMU has the same cause. In the same test loop it was stopped for 26.2 of 49.6 seconds.
- Experiment
- CPU tuning results: each sandbox with and without pod overhead →
3.6× → 1.8×Unpack node_modules in gVisor, compared with a plain container. First as shipped, then with pod overhead.Tuning run. Pods with 1 CPU and 2 GiB. Baseline: runc in the same group of pods.
Nitro’s default limits
- What happened
- A clone of a large repo took 33.5 s in an AWS Nitro Sandbox pod. A plain container on the same cluster took 6.2 s.
- Why
- Work in a Nitro pod is as fast as in a container. But AWS sets a limit for each pod on disk, network and DNS. The default disk limit that we measured is 1,500 operations each second. A clone writes many files, thus it reaches this limit and then waits.
- What we changed
- We removed the disk limit with a pod annotation.
- Result
- The same clone took 7.1 s.
- Other sandboxes
- Only AWS Nitro Sandboxes have these limits.
- Experiment
- Nitro experiment: why AWS Nitro behaves the way it does →
Each limit and its measured value →
33.5 s → 7.1 sClone a large repo in a Nitro pod, isolated mode. First with the default disk limit, then with no limit.Separate EKS Auto Mode cluster, m8id.xlarge, pods with 1 CPU and 2 GiB. Baseline: runc on that cluster, 6.2 s.
A VM inside a VM
- What happened
- Kata sent data on the network 7.3× slower than a plain container on a cloud node.
- Why
- A cloud node is a VM. Kata starts one more VM in it for each pod. Each packet goes through the guest kernel, the host kernel and two hypervisors. Look from any layer to see the guest kernel, the host kernel and the hypervisor →
- What we changed
- We ran the same tests on a bare-metal server. There, the Kata VM is the only VM. This is not a setting: you must change the machine.
- Result
- Network send improved from 7.3× to 3.9×. The file cost of the shared folder stayed: 53× on the cloud node and 37× on bare metal.
- Other sandboxes
- Each sandbox that starts a VM has this cause. Kata with Firecracker sent data 9.3× slower on the cloud node and 3.3× on bare metal. gVisor in KVM mode unpacked node_modules 13× slower on the cloud node and 4.4× on bare metal. Sysbox and gVisor in its default mode start no VM.
- Experiment
- Bare-metal experiment: the same sandboxes on a server with no cloud VM →
7.3× → 3.9×Kata sends data, compared with a plain container. First on a cloud node, then on bare metal.Bare-metal run, m7i.metal-24xl, with a nested control on the same hardware. Baseline: runc on each machine.
What still costs time
- A VM must start. In the tuning run, a Kata pod took 1.0 to 2.5 seconds to start when we measured below Kubernetes. A plain container took 0.2 seconds. No setting that we tested changed this. Through Kubernetes, with default settings, a short pod completed 1.4 to 3.2 seconds later in Kata and 3.1 seconds later in AWS Nitro. These are times for a short pod to complete. They are not times for an application to become ready. Start-up tuning results → Short pod for each sandbox →
- Saved writes are slow in a VM. A plain container saves 19,900 writes each second. A Kata block disk saves approximately 2,500. Disk tuning results →
- Network send stays slow in Kata. After tuning, it is approximately one third of the speed of a plain container. Network tuning results →
- gVisor kernel calls stay slow. The fastest kernel call is 29× slower than in a plain container. gVisor tuning results →