In my made-up 8 service
architecture we went from 5 things
to optimise up to 32
Gareth Rushgrove
The Bad
Slide 29
Slide 29 text
We went from 3 network hops
to, er, more depending on
the request
Gareth Rushgrove
The Bad
Slide 30
Slide 30 text
We ignored the cost of
serialisation/deserialisation
(JSON can be expensive)
Gareth Rushgrove
The Bad
Slide 31
Slide 31 text
The operational overhead
just jumped considerably
Gareth Rushgrove
The Bad
Slide 32
Slide 32 text
Lots more network traffic. Watch
out for latency in particular
Gareth Rushgrove
The Bad
Slide 33
Slide 33 text
Without request tracing
you’re doomed
Gareth Rushgrove
The Bad
Slide 34
Slide 34 text
Granular services are easier
to optimise individually
Gareth Rushgrove
The Good
Slide 35
Slide 35 text
Individual services can be
scaled independently
Gareth Rushgrove
The Good
Slide 36
Slide 36 text
Debugging with
Containers
Is that process inside or outside a container?
Slide 37
Slide 37 text
Problems with free and top
Gareth Rushgrove
Slide 38
Slide 38 text
Gareth Rushgrove
$ free
total used free shared buffers cached
Mem: 1024444 864140 160304 5024 50008 637736
-/+ buffers/cache: 176396 848048
Swap: 473084 16 473068
$ docker exec test-container free
total used free shared buffers cached
Mem: 1024444 866440 158004 5024 50000 637732
-/+ buffers/cache: 178708 845736
Swap: 473084 16 473068
Can a container use that memory?
Slide 39
Slide 39 text
memory stats come from the proc
filesystem: /proc/meminfo, /
proc/vmstat, etc.
Gareth Rushgrove
Slide 40
Slide 40 text
/proc/meminfo and
/proc/vmstat are not
aware of cgroups
Gareth Rushgrove
Slide 41
Slide 41 text
Problems with ps
Gareth Rushgrove
Slide 42
Slide 42 text
Gareth Rushgrove
$ ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
...
999 1807 0.2 11.4 867624 464572 ? Ssl 09:38 0:21 mysqld
Is this process in a container?
Slide 43
Slide 43 text
Gareth Rushgrove
$ ps -eo ucmd,cgroup
COMMAND CGROUP
...
mysqld 9:perf_event:/docker/61e76d2c39121282474ff895b9b3ba2addd775cdea6d2ba89ce76c28
Which container is that?
Slide 44
Slide 44 text
Gareth Rushgrove
Sysdig
Slide 45
Slide 45 text
Provides a Kernel module, which
hooks into cgroups and
namespaces
Gareth Rushgrove
Slide 46
Slide 46 text
Gareth Rushgrove
$ sudo sysdig -c topcontainers_cpu
CPU% container.name
-----------------------------------------------------------------------
90.13% mysql
15.93% wordpress1
7.27% haproxy
3.46% wordpress2
CPU usage across containers
Slide 47
Slide 47 text
Gareth Rushgrove
$ sudo sysdig -pc -c topprocs_cpu container.name=client
CPU% Process container.name
----------------------------------------------
02.69% bash client
31.04% curl client
0.74% sleep client
CPU usage in a single container
Gareth Rushgrove
$ sudo sysdig -pc -A -c echo_fds "fd.ip=172.17.0.3 and fd.ip=172.17.0.7"
------ Write 103B to [haproxy] [d468ee81543a] 172.17.0.7:37557->172.17.0.3:80 (hapr
GET / HTTP/1.1
User-Agent: curl/7.35.0
Host: 172.17.0.7
Accept: */*
X-Forwarded-For: 172.17.0.8
------ Read 103B from [wordpress1] [12b8c6a04031] 172.17.0.7:37557->172.17.0.3:80 (
GET / HTTP/1.1
User-Agent: curl/7.35.0
Host: 172.17.0.7
Accept: */*
X-Forwarded-For: 172.17.0.8
------ Write 346B to [wordpress1] [12b8c6a04031] 172.17.0.7:37557->172.17.0.3:80 (a
HTTP/1.1 302 Found
Date: Sat, 21 Feb 2015 22:19:18 GMT
Traffic between containers
Slide 50
Slide 50 text
Don’t expect existing debugging
tools to work
Gareth Rushgrove
The Bad
Slide 51
Slide 51 text
New tools are emerging. Often
with better interfaces
Gareth Rushgrove
The Good
Slide 52
Slide 52 text
Container Overhead
Count the performance penalties
Slide 53
Slide 53 text
Gareth Rushgrove
Slide 54
Slide 54 text
Containers add very little
overhead
Gareth Rushgrove
The Good
Slide 55
Slide 55 text
Gareth Rushgrove
Slide 56
Slide 56 text
Gareth Rushgrove
Slide 57
Slide 57 text
Memory cgroups can be
expensive
Gareth Rushgrove
The Bad
Slide 58
Slide 58 text
By default, the memory subsystem
uses 40 bytes of memory per
physical page on x86_64 systems.
These resources are consumed
even if memory is not used in any
hierarchy
Gareth Rushgrove
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Resource_Management_Guide/sec-memory.html
Slide 59
Slide 59 text
Container networking is hard.
Overlay networks make it easy.
But slow.
Gareth Rushgrove
The Bad