lightweight os containers cntr - usenix · kernel space process user space cntrfs cntrfs server...

22
CNTR Lightweight OS Containers Jörg Thalheim, Pramod Bhatotia Baris Kasikci Pedro Fonseca USENIX ATC 2018

Upload: others

Post on 29-May-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lightweight OS Containers CNTR - USENIX · Kernel space Process User space CntrFS CntrFS server Request VFS FUSE Process and CntrFS server can run in different namespaces (container)

CNTRLightweight OS Containers

Jörg Thalheim, Pramod Bhatotia Baris KasikciPedro Fonseca

USENIX ATC 2018

Page 2: Lightweight OS Containers CNTR - USENIX · Kernel space Process User space CntrFS CntrFS server Request VFS FUSE Process and CntrFS server can run in different namespaces (container)

Container-based virtualization

Lightweightisolation

Namespaces

Process-levelvirtualization

Cgroups

Extensively used in production

2

Page 3: Lightweight OS Containers CNTR - USENIX · Kernel space Process User space CntrFS CntrFS server Request VFS FUSE Process and CntrFS server can run in different namespaces (container)

Why lightweight containers are important?

● Fast deployment

● Low resource usage

● Low build times

3

Page 4: Lightweight OS Containers CNTR - USENIX · Kernel space Process User space CntrFS CntrFS server Request VFS FUSE Process and CntrFS server can run in different namespaces (container)

Containers are NOT lightweight anymore!

Only 33% data was accessedby the applications!

Lower is

better

Limitations: Inefficient development and deployment of containers4

Case study: Top 50 Docker Hub container images

Page 5: Lightweight OS Containers CNTR - USENIX · Kernel space Process User space CntrFS CntrFS server Request VFS FUSE Process and CntrFS server can run in different namespaces (container)

Why containers are becoming heavyweight?

Build description: e.g. Dockerfile

Application (MySQL)

Additional tools (Coreutils, ...)

Container images are large due to additional tools!

Host

Container

Containerimage

5

Page 6: Lightweight OS Containers CNTR - USENIX · Kernel space Process User space CntrFS CntrFS server Request VFS FUSE Process and CntrFS server can run in different namespaces (container)

Additional tools

● Why are they important?○ Debugging, inspection, monitoring, management, etc.

6

Additional tools are NOT used in the common use case

● What are these additional tools?○ Debuggers, editors, coreutils, shell, etc.

Page 7: Lightweight OS Containers CNTR - USENIX · Kernel space Process User space CntrFS CntrFS server Request VFS FUSE Process and CntrFS server can run in different namespaces (container)

Cntr: Split container images

Slim image Fat image

Slim containerRuns the application

Fat containerServes tools to the user

Original image

CNTRProvides access

Common use case Deployed on demand

7

Page 8: Lightweight OS Containers CNTR - USENIX · Kernel space Process User space CntrFS CntrFS server Request VFS FUSE Process and CntrFS server can run in different namespaces (container)

Design

Page 9: Lightweight OS Containers CNTR - USENIX · Kernel space Process User space CntrFS CntrFS server Request VFS FUSE Process and CntrFS server can run in different namespaces (container)

Design goals

● Generality○ Support a wide range of workflows (debugging, inspection, etc.)

● Efficiency ○ No performance overhead on the application

● Transparency ○ No modifications to the OS, container engine, and application

9

Page 10: Lightweight OS Containers CNTR - USENIX · Kernel space Process User space CntrFS CntrFS server Request VFS FUSE Process and CntrFS server can run in different namespaces (container)

Overview

Nested namespace

App (MySQL)

CntrFSserver

Slim container Fat containerUser

Access tools via FUSE

Access the application

Tools(Gdb, coreutils...)

Access tools

10

Page 11: Lightweight OS Containers CNTR - USENIX · Kernel space Process User space CntrFS CntrFS server Request VFS FUSE Process and CntrFS server can run in different namespaces (container)

Nested namespace

● Implemented on top of existing OS features○ Namespaces○ FUSE

/

var usr

lib

cntrusr

bin

mysql

bin

gdb

“Slim” image

“Fat” image

● Nested namespace filesystem view

11

Page 12: Lightweight OS Containers CNTR - USENIX · Kernel space Process User space CntrFS CntrFS server Request VFS FUSE Process and CntrFS server can run in different namespaces (container)

“Fat”container

Nested namespace

POSIX filesystem

API

System callKernel space

Process

User space

CntrFS

CntrFSserver

Request

VFS FUSE

Process and CntrFS server can run in different namespaces (container)12

Page 13: Lightweight OS Containers CNTR - USENIX · Kernel space Process User space CntrFS CntrFS server Request VFS FUSE Process and CntrFS server can run in different namespaces (container)

● Easy to use○

Implementation● Lightweight deployment

○ Single 1.2 MB static binary

root@fat-container $ cntr attach slim-containerroot@slim-container $

● Supports all popular containers○ Docker, LXC, LXD, Systemd-nspawn, rkt, etc.

13

Page 14: Lightweight OS Containers CNTR - USENIX · Kernel space Process User space CntrFS CntrFS server Request VFS FUSE Process and CntrFS server can run in different namespaces (container)

Evaluation

Page 15: Lightweight OS Containers CNTR - USENIX · Kernel space Process User space CntrFS CntrFS server Request VFS FUSE Process and CntrFS server can run in different namespaces (container)

Evaluation● Questions:

1. Is the implementation complete?2. What are the performance overheads?3. How effective is the approach in reducing container image sizes?

● Experimental testbed:○ M4.xlarge VM on EC2 ○ 100 GB device of type GP2 (SSD-backed network storage) ○ Base filesystem: Ext4

15

Page 16: Lightweight OS Containers CNTR - USENIX · Kernel space Process User space CntrFS CntrFS server Request VFS FUSE Process and CntrFS server can run in different namespaces (container)

○ Unsupported tests are minor Linux-specific implementation details ○ 3 of 4 unsupported tests also don’t work on overlayfs (default on Docker)

#1: Completeness

● Benchmark: Xfstests regression test suite

Cntr can already be used in production

Tests Supported tests

94 90 (95.74%)

16

Page 17: Lightweight OS Containers CNTR - USENIX · Kernel space Process User space CntrFS CntrFS server Request VFS FUSE Process and CntrFS server can run in different namespaces (container)

#2 (a): Overheads for the “slim” container

17

0%For the common use case

of accessing the slim container

Page 18: Lightweight OS Containers CNTR - USENIX · Kernel space Process User space CntrFS CntrFS server Request VFS FUSE Process and CntrFS server can run in different namespaces (container)

#2 (b): Overheads for the “fat” container

Cntr incurs reasonable overhead for management tasks

Lower is

better

1.5x

18

Phoronix test suite

Page 19: Lightweight OS Containers CNTR - USENIX · Kernel space Process User space CntrFS CntrFS server Request VFS FUSE Process and CntrFS server can run in different namespaces (container)

#3: Effectiveness

Average reduction is 66% of the container size

Containers with static Go binaries

Majority of containers contains unnecessary data

Top 50 containers on Docker Hub

19

Page 20: Lightweight OS Containers CNTR - USENIX · Kernel space Process User space CntrFS CntrFS server Request VFS FUSE Process and CntrFS server can run in different namespaces (container)

Demo!

Page 21: Lightweight OS Containers CNTR - USENIX · Kernel space Process User space CntrFS CntrFS server Request VFS FUSE Process and CntrFS server can run in different namespaces (container)

Demo setup

21

Host:NixOS

“Slim” container:Busybox

Access Via CNTR

$ sudo docker run --name mycontainer busybox$ sudo cntr attach mycontainer

Page 22: Lightweight OS Containers CNTR - USENIX · Kernel space Process User space CntrFS CntrFS server Request VFS FUSE Process and CntrFS server can run in different namespaces (container)

Summary● Containers are NOT lightweight in practice

○ Limitation: Inefficient development and deployment of containers

● CNTR: Lightweight OS Containers○ Splits the container image into fat and slim parts○ Leverages FUSE to expose additional tools in a nested namespace

Generic + Transparent + Efficient

Try it out! https://github.com/Mic92/cntr

22