Docker でコンテナ複数起動時の性能を見てみる.


漢なら Docker でコンテナ立てまくりたいですよね! 

漢なら黙って世の中のデファクトスタンダードと化したと過言でもない aobench をたくさん走らせてベンチマークですね.

http://code.google.com/p/aobench/

aobench コンテナは public repo にあるので, "あなたと docker + aobench, 今すぐベンチマーク", が出来ます.

https://index.docker.io/u/syoyo/aobench/

```
$ sudo docker pull syoyo/aobench
```

## 実行スクリプト

こんな感じのを用意します.

```
#!/bin/bash

for i in `seq 1 100`;
do
  time docker run syoyo/aobench /bin/ao &
done
```

## 実行

coreos な host OS + docker で実行してみます.
docker のバージョンは 0.7.5 です.

```
$ docker version
Client version: 0.7.5
Go version (client): go1.2
Git commit (client): c348c04
Server version: 0.7.5
Git commit (server): c348c04
Go version (server): go1.2
Last stable version: 0.8.0, please update docker
```

```
$ ./bench.sh
[error] commands.go:2437 Error receiveStdout: Unrecognized input header
[error] commands.go:2437 Error receiveStdout: Unrecognized input header
2014/02/14 12:47:14 Unrecognized input header

real	0m9.108s
user	0m0.016s
sys	0m0.065s
[error] commands.go:2437 Error receiveStdout: Unrecognized input header
2014/02/14 12:47:20 Unrecognized input header

real	0m15.109s
user	0m0.014s
sys	0m0.111s
[error] commands.go:2437 Error receiveStdout: Unrecognized input header
2014/02/14 12:47:31 Error: start: No such container: d5924932228976d5ffd22bbf014fd0b2e44f484559cb85fb4ab926a4a7dcc356

real	0m25.810s
user	0m0.010s
sys	0m0.103s
[error] commands.go:2437 Error receiveStdout: Unrecognized input header
2014/02/14 12:47:33 Error: start: No such container: 8c319b2208e7b957c513e0082774a596dfa11c28080831400483ab3c4a671ee9

real	0m28.050s
user	0m0.024s
sys	0m0.090s
2014/02/14 12:47:35 Unrecognized input header

real	0m26.751s
user	0m0.013s
sys	0m0.116s
[error] commands.go:2437 Error receiveStdout: Unrecognized input header
[error] commands.go:2437 Error receiveStdout: Unrecognized input header
[error] commands.go:2437 Error receiveStdout: Unrecognized input header
2014/02/14 12:47:49 Error: start: No such container: e0a81da7907429020f3d5df9acc62f2bef6ef596c0210424b978268f7678d2ad

real	0m42.989s
user	0m0.019s
sys	0m0.103s
[error] commands.go:2437 Error receiveStdout: Unrecognized input header
2014/02/14 12:47:57 Error: start: No such container: a48800197e65e4c3b41216ac61aee99c7e9e931b8afdfaa5c078313bc9bd6943

real	0m51.333s
user	0m0.016s
sys	0m0.090s
[error] commands.go:2437 Error receiveStdout: Unrecognized input header
[error] commands.go:2437 Error receiveStdout: Unrecognized input header
[error] commands.go:2437 Error receiveStdout: Unrecognized input header
[error] commands.go:2437 Error receiveStdout: Unrecognized input header
2014/02/14 12:48:24 Error: start: No such container: 3c4d625807441e7f1a3db7551576fc25db1a5d8817c8fd1883a7b45da72df93b

real	1m16.676s
user	0m0.013s
sys	0m0.086s
2014/02/14 12:48:25 Error: start: No such container: 6dc4b7f1e97e47a9ff0a232545fd5658609217d01ad5aebac80979644a05af25

real	1m15.886s
user	0m0.010s
sys	0m0.065s
2014/02/14 12:48:42 Error: start: Cannot start container f908b2d0d517bd5bc53dfb0be4d8de5f70a4e694a0390134de2acba858a7f7a9: The container failed to start due to timed out.

real	1m36.579s
user	0m0.021s
sys	0m0.099s
2014/02/14 12:48:44 Error: start: Cannot start container 41b0b85c4bdb84d22dcccb2ea98d5cc66025941915fba244d79ef31ee1b6553c: The container failed to start due to timed out.

real	1m38.737s
user	0m0.023s
sys	0m0.097s
2014/02/14 12:48:46 Error: start: Cannot start container 6b6031c6f4c02564e1b0784766664978c56b38809ddd49b614bf767329ce4bfe: The container failed to start due to timed out.

real	1m41.057s
user	0m0.015s
sys	0m0.092s
[error] commands.go:2437 Error receiveStdout: Unrecognized input header
Output ao.ppm

real	2m2.168s
user	0m0.021s
sys	0m0.144s
Output ao.ppm

real	2m8.882s
user	0m0.011s
sys	0m0.081s
2014/02/14 12:49:19 Error: start: Cannot start container 1f189a20cdb4e5518324bdd86b6e02a8391eeeb9af1b355b53e48b3da2c2aa4f: The container failed to start due to timed out.

real	2m14.083s
user	0m0.020s
sys	0m0.113s
2014/02/14 12:49:20 Error: start: Cannot start container e917828f49cc94a4e424010ef85078fdd3fcbc36a898947573ef351b53493e6d: The container failed to start due to timed out.
…
```

なんたるちや! 100 個連続で立てようとしたらダメでしたね. まあカーネルパニックになるよりはマシでしょうか.

もう少しやさしくしてみます.

```
#!/bin/bash

for i in `seq 1 10`;
do
  time docker run syoyo/aobench /bin/ao &
done
```

```
$ ./bench.sh
Output ao.ppm

real	0m41.578s
user	0m0.019s
sys	0m0.090s
Output ao.ppm

real	0m43.716s
user	0m0.017s
sys	0m0.074s
Output ao.ppm

real	0m46.294s
user	0m0.015s
sys	0m0.121s
Output ao.ppm

real	0m47.212s
user	0m0.015s
sys	0m0.082s
Output ao.ppm
Output ao.ppm

real	0m48.089s
user	0m0.027s
sys	0m0.149s

real	0m48.066s
user	0m0.024s
sys	0m0.115s
Output ao.ppm

real	0m48.433s
user	0m0.028s
sys	0m0.122s
Output ao.ppm
Output ao.ppm

real	0m49.067s
Output ao.ppm

real	0m49.077s
user	0m0.013s
sys	0m0.084s
user	0m0.016s
sys	0m0.117s

real	0m49.413s
user	0m0.016s
sys	0m0.115s
```

出来ました. しかし 10 個じゃ物足りないですね. やはり最低 100 個は立てたいですね. Docker 0.8 など今後に期待でしょうか.