GCEとEC2をベンチマークしてみる

いろんな記事でみんなやってるけど自分でもやってみる。

- 基本的にチューニングなし
- 東京リージョン
- 無料枠
- コンソールでUbuntu16.04起動してそのままベンチとる(なにもさわらない)
- 3回くらい打ってみて、誤差が10%くらいだったら1番いい結果を採用
- Unixベンチ(CPU) と インターネットへのアクセス速度、同セグメント同士の内部通信速度
- 家にちょうどCPU 2CoreのLinuxサーバ(1万6千円)いたのでついでに計測

## とりあえず結果

| 環境 | マシンタイプ          | 仮想 CPU 数 | メモリ | 料金（1時間） | １Core/1ヶ月 | UnixBench | 回線速度(ダウンロード) | 回線速度(アップロード) | 内部通信  |
|------|-----------------------|-------------|--------|---------------|--------------|-----------|------------------------|------------------------|-----------|
| GCP  | n1-standard-2         | 2           | 7.5GB  | $0.13         | $47.74       | 2412.7    | 513.41Mbps             | 268.80 Mbps            | 3.91 Gbps |
| EC2  | m4.large              | 2           | 8GB    | $0.14         | $50.04       | 2170.1    | 251.58 Mbps            | 173.81 Mbps            | 568 Mbps  |
| 自宅 | PRIMERGY TX100   S3P  | 2           | 4GB    | $0            | $6<br>12分割払い<br>電気代考えない           |3321.5      | 79.83Mbps              | 35.83 Mbps             | -     |

コスト: 安鯖 >> GCE > EC2
CPU性能: 安鯖 >> GCE > EC2
外部通信速度: GCE > EC2 >> OCNマンションプラン
内部通信速度: GCE > EC2

想像以上にNTT-Xで衝動買いしたTX100が早かった。。。

## Unixベンチ

Ubuntu16.04で [こちら](https://github.com/kdlucas/byte-unixbench) のツールの `./Run` を実行

### GCE

```
Benchmark Run: Mon Dec 26 2016 04:38:32 - 05:06:36
2 CPUs in system; running 1 parallel copy of tests

Dhrystone 2 using register variables       32889913.9 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                     4158.4 MWIPS (9.9 s, 7 samples)
Execl Throughput                               3813.4 lps   (30.0 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks       1163952.7 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks          309796.7 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks       3187773.4 KBps  (30.0 s, 2 samples)
Pipe Throughput                             2382718.4 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                  99231.4 lps   (10.0 s, 7 samples)
Process Creation                              10327.3 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                   9612.0 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                   1580.4 lpm   (60.0 s, 2 samples)
System Call Overhead                        3780852.8 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0   32889913.9   2818.3
Double-Precision Whetstone                       55.0       4158.4    756.1
Execl Throughput                                 43.0       3813.4    886.8
File Copy 1024 bufsize 2000 maxblocks          3960.0    1163952.7   2939.3
File Copy 256 bufsize 500 maxblocks            1655.0     309796.7   1871.9
File Copy 4096 bufsize 8000 maxblocks          5800.0    3187773.4   5496.2
Pipe Throughput                               12440.0    2382718.4   1915.4
Pipe-based Context Switching                   4000.0      99231.4    248.1
Process Creation                                126.0      10327.3    819.6
Shell Scripts (1 concurrent)                     42.4       9612.0   2267.0
Shell Scripts (8 concurrent)                      6.0       1580.4   2634.0
System Call Overhead                          15000.0    3780852.8   2520.6
                                                                   ========
System Benchmarks Index Score                                        1623.4

------------------------------------------------------------------------
Benchmark Run: Mon Dec 26 2016 05:06:36 - 05:34:42
2 CPUs in system; running 2 parallel copies of tests

Dhrystone 2 using register variables       41560354.9 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                     7322.8 MWIPS (10.0 s, 7 samples)
Execl Throughput                               6853.3 lps   (30.0 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks       1271128.5 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks          335093.4 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks       3914204.4 KBps  (30.0 s, 2 samples)
Pipe Throughput                             2586059.3 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                 446484.4 lps   (10.0 s, 7 samples)
Process Creation                              21331.9 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                  12752.2 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                   1649.5 lpm   (60.0 s, 2 samples)
System Call Overhead                        5420983.2 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0   41560354.9   3561.3
Double-Precision Whetstone                       55.0       7322.8   1331.4
Execl Throughput                                 43.0       6853.3   1593.8
File Copy 1024 bufsize 2000 maxblocks          3960.0    1271128.5   3209.9
File Copy 256 bufsize 500 maxblocks            1655.0     335093.4   2024.7
File Copy 4096 bufsize 8000 maxblocks          5800.0    3914204.4   6748.6
Pipe Throughput                               12440.0    2586059.3   2078.8
Pipe-based Context Switching                   4000.0     446484.4   1116.2
Process Creation                                126.0      21331.9   1693.0
Shell Scripts (1 concurrent)                     42.4      12752.2   3007.6
Shell Scripts (8 concurrent)                      6.0       1649.5   2749.2
System Call Overhead                          15000.0    5420983.2   3614.0
                                                                   ========
System Benchmarks Index Score                                        2412.7
```

### EC2

```
Benchmark Run: Mon Dec 26 2016 15:13:30 - 15:41:54
2 CPUs in system; running 1 parallel copy of tests

Dhrystone 2 using register variables       31797472.0 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                     3400.5 MWIPS (9.9 s, 7 samples)
Execl Throughput                               4030.8 lps   (29.9 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks       1101694.9 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks          295454.1 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks       3092616.0 KBps  (30.0 s, 2 samples)
Pipe Throughput                             2132125.2 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                  45794.5 lps   (10.0 s, 7 samples)
Process Creation                               9804.2 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                   9879.6 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                   1540.6 lpm   (60.0 s, 2 samples)
System Call Overhead                        3325235.7 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0   31797472.0   2724.7
Double-Precision Whetstone                       55.0       3400.5    618.3
Execl Throughput                                 43.0       4030.8    937.4
File Copy 1024 bufsize 2000 maxblocks          3960.0    1101694.9   2782.1
File Copy 256 bufsize 500 maxblocks            1655.0     295454.1   1785.2
File Copy 4096 bufsize 8000 maxblocks          5800.0    3092616.0   5332.1
Pipe Throughput                               12440.0    2132125.2   1713.9
Pipe-based Context Switching                   4000.0      45794.5    114.5
Process Creation                                126.0       9804.2    778.1
Shell Scripts (1 concurrent)                     42.4       9879.6   2330.1
Shell Scripts (8 concurrent)                      6.0       1540.6   2567.7
System Call Overhead                          15000.0    3325235.7   2216.8
                                                                   ========
System Benchmarks Index Score                                        1447.6

------------------------------------------------------------------------
Benchmark Run: Mon Dec 26 2016 15:41:54 - 16:10:22
2 CPUs in system; running 2 parallel copies of tests

Dhrystone 2 using register variables       39501029.1 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                     6052.8 MWIPS (10.1 s, 7 samples)
Execl Throughput                               6302.2 lps   (29.9 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks       1195681.5 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks          314091.6 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks       3607481.0 KBps  (30.0 s, 2 samples)
Pipe Throughput                             2347094.6 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                 335122.9 lps   (10.0 s, 7 samples)
Process Creation                              18507.5 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                  12197.8 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                   1584.2 lpm   (60.0 s, 2 samples)
System Call Overhead                        4767938.8 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0   39501029.1   3384.8
Double-Precision Whetstone                       55.0       6052.8   1100.5
Execl Throughput                                 43.0       6302.2   1465.6
File Copy 1024 bufsize 2000 maxblocks          3960.0    1195681.5   3019.4
File Copy 256 bufsize 500 maxblocks            1655.0     314091.6   1897.8
File Copy 4096 bufsize 8000 maxblocks          5800.0    3607481.0   6219.8
Pipe Throughput                               12440.0    2347094.6   1886.7
Pipe-based Context Switching                   4000.0     335122.9    837.8
Process Creation                                126.0      18507.5   1468.9
Shell Scripts (1 concurrent)                     42.4      12197.8   2876.9
Shell Scripts (8 concurrent)                      6.0       1584.2   2640.4
System Call Overhead                          15000.0    4767938.8   3178.6
                                                                   ========
System Benchmarks Index Score                                        2170.1
```

## ネットワークベンチ

[SpeedTest](http://www.speedtest.net/)を利用してベンチを取ってみる
ちなみにどっちも東京Regionから

http://archive.getdeb.net/getdeb/ubuntu/pool/apps/s/speedtest-cli/python-speedtest-cli_1.0.1-1~getdeb1_all.deb
をダウンロードして `speedtest-cli --server 6508 #Yokohama` を打つだけ
念のため3回打っても同じくらいだった

AWSはちゃんと東京っぽいけどGCEから打つと `at2wn (Yokohama) [8338.92 km]` ？？？
特殊なネットワークなのかな？

### GCE

```
root@instance-3:~# speedtest-cli --server 6508
Retrieving speedtest.net configuration...
Testing from Google Cloud Platform (104.198.127.68)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by at2wn (Yokohama) [8338.92 km]: 28.419 ms
Testing download speed................................................................................
Download: 513.41 Mbit/s
Testing upload speed....................................................................................................
Upload: 268.80 Mbit/s
```

### EC2

```
$ speedtest-cli --server 6508
Retrieving speedtest.net configuration...
Testing from Amazon (52.197.14.75)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by at2wn (Yokohama) [24.99 km]: 36.746 ms
Testing download speed................................................................................
Download: 251.58 Mbit/s
Testing upload speed....................................................................................................
Upload: 173.81 Mbit/s
```

## 内部通信

iperfを使って内部ネットワーク(同セグ)でのベンチマークをとってみる
`apt install iperf` して `iperf -s` しているサーバに `iperf -c 10.140.0.3` でアクセスしてみる

### GCE

```
------------------------------------------------------------
Client connecting to 10.140.0.3, TCP port 5001
TCP window size: 45.0 KByte (default)
------------------------------------------------------------
[  3] local 10.140.0.2 port 59318 connected with 10.140.0.3 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec  4.55 GBytes  3.91 Gbits/sec
```

### EC2

```
$ iperf -c 10.0.0.206
------------------------------------------------------------
Client connecting to 10.0.0.206, TCP port 5001
TCP window size:  325 KByte (default)
------------------------------------------------------------
[  3] local 10.0.0.65 port 54782 connected with 10.0.0.206 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec   678 MBytes   568 Mbits/sec
```

## おまけ

1万6千円で買った[PRIMERGY TX100 S3P](http://jp.fujitsu.com/platform/server/primergy/product-navi/html/tx100s3-201110-pyt103t3s.html) のベンチ結果(回線はフレッツ光＋OCN)
- CPU 2 Core
- メモリ 4GB
- HDD 10TB(ただのファイル置き場)

### Unixベンチ

```
Benchmark Run: 月 12月 26 2016 17:44:45 - 18:12:57
2 CPUs in system; running 1 parallel copy of tests

Dhrystone 2 using register variables       36316846.0 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                     4558.6 MWIPS (9.9 s, 7 samples)
Execl Throughput                               5422.4 lps   (29.9 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks       1139181.1 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks          334280.7 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks       2469074.4 KBps  (30.0 s, 2 samples)
Pipe Throughput                             2476910.0 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                 233752.1 lps   (10.0 s, 7 samples)
Process Creation                              16076.8 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                  12390.7 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                   2217.9 lpm   (60.0 s, 2 samples)
System Call Overhead                        4104422.6 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0   36316846.0   3112.0
Double-Precision Whetstone                       55.0       4558.6    828.8
Execl Throughput                                 43.0       5422.4   1261.0
File Copy 1024 bufsize 2000 maxblocks          3960.0    1139181.1   2876.7
File Copy 256 bufsize 500 maxblocks            1655.0     334280.7   2019.8
File Copy 4096 bufsize 8000 maxblocks          5800.0    2469074.4   4257.0
Pipe Throughput                               12440.0    2476910.0   1991.1
Pipe-based Context Switching                   4000.0     233752.1    584.4
Process Creation                                126.0      16076.8   1275.9
Shell Scripts (1 concurrent)                     42.4      12390.7   2922.3
Shell Scripts (8 concurrent)                      6.0       2217.9   3696.5
System Call Overhead                          15000.0    4104422.6   2736.3
                                                                   ========
System Benchmarks Index Score                                        1975.4

------------------------------------------------------------------------
Benchmark Run: 月 12月 26 2016 18:12:57 - 18:41:09
2 CPUs in system; running 2 parallel copies of tests

Dhrystone 2 using register variables       71781181.4 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                     9004.1 MWIPS (9.9 s, 7 samples)
Execl Throughput                              11455.9 lps   (29.9 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks       1368120.2 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks          380983.4 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks       3480067.5 KBps  (30.0 s, 2 samples)
Pipe Throughput                             4889444.2 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                 770362.3 lps   (10.0 s, 7 samples)
Process Creation                              30494.1 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                  18946.3 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                   2379.6 lpm   (60.0 s, 2 samples)
System Call Overhead                        6507685.5 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0   71781181.4   6150.9
Double-Precision Whetstone                       55.0       9004.1   1637.1
Execl Throughput                                 43.0      11455.9   2664.2
File Copy 1024 bufsize 2000 maxblocks          3960.0    1368120.2   3454.8
File Copy 256 bufsize 500 maxblocks            1655.0     380983.4   2302.0
File Copy 4096 bufsize 8000 maxblocks          5800.0    3480067.5   6000.1
Pipe Throughput                               12440.0    4889444.2   3930.4
Pipe-based Context Switching                   4000.0     770362.3   1925.9
Process Creation                                126.0      30494.1   2420.2
Shell Scripts (1 concurrent)                     42.4      18946.3   4468.5
Shell Scripts (8 concurrent)                      6.0       2379.6   3966.1
System Call Overhead                          15000.0    6507685.5   4338.5
                                                                   ========
System Benchmarks Index Score                                        3321.5
```

### speedtest

```
# speedtest-cli --server 6508
Retrieving speedtest.net configuration...
Testing from OCN (153.205.138.69)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by at2wn (Yokohama) [24.99 km]: 22.115 ms
Testing download speed................................................................................
Download: 79.83 Mbit/s
Testing upload speed...................................................................................
.................
Upload: 35.83 Mbit/s
```