More Related Content
Similar to JAWS目黒 EC2チューニングTips #jawsmeguro #jawsug (20)
More from Yasuhiro Matsuo (11)
JAWS目黒 EC2チューニングTips #jawsmeguro #jawsug
- 2. 2
Who am I ?
• 名前
– 松尾康博 ( @understeer )
• 所属
– アマゾンデータサービスジャパン株式会社
– ソリューションアーキテクト
– ビッグデータ、製造業HPCのお客様を担当
• 経歴
– 九州大学でスパコンの効率化研究
– SIerで 分散キューの開発・導入、分散処理研究
– Web系スタートアップCTO
– SIerで仮想化基盤の研究・導入・運用
– 現職
- 4. 4
TL;DR
だいたいはここ読めばOK
• (PFC306) Performance Tuning Amazon
EC2 Instances | AWS re:Invent 2014
– http://www.slideshare.net/AmazonWebServices/pfc3
06-performance-tuning-amazon-ec2-instances-aws-
reinvent-2014
• Your Linux AMI: Optimization and
Performance (CPN302) | AWS re:Invent
2013
– http://www.slideshare.net/AmazonWebServices/your-linux-ami-
optimization-and-performance-cpn302-aws-reinvent-2013
• Recommendations for successfully
deploying Aerospike on Amazon EC2
– http://www.aerospike.com/docs/deploy_guides/aws/recom
mendations/
• Red Hat Enterprise Linux 6パフォーマンス
チューニングガイド
– https://access.redhat.com/documentation/ja-
JP/Red_Hat_Enterprise_Linux/6/html/Performance_Tuning
_Guide/index.html
- 6. 6
EC2で使える仮想化タイプ: PV / HVM
• Linux EC2仮想化タイプ
– 準仮想化(Paravirtual, PV)
– 完全仮想化(Hardware-assisted VM, HVM)
• 昔
– 準仮想化(PV) →速い
– 完全仮想化(HVM) →遅い(I/O, メモリ)
• 今
– PV on HVMドライバ (PVHVM) で速度改善
– 2.6.36以降でマージされている
• RHEL(CentOS)6の 2.6.32にバックポート
– Intel VT-x, VT-d, EPTのアシスト
– 現行インスタンスタイプは全てHVM対応
http://wiki.xen.org/wiki/PV_on_HVM
PV on HVMドライバ http://wiki.xen.org/wiki/Xen_Linux_PV_on_HVM_drivers
EC2の仮想化タイプ https://docs.aws.amazon.com/ja_jp/AWSEC2/latest/UserGuide/virtualization_types.html
- 7. 7
HVMインスタンスのメリット
• 拡張命令
– AVX ( Advanced Vector eXtensions)
• SIMD拡張命令
– AES-NI (Advanced Encryption Standard Instructions Set)
– Turbo Boost
• メモリ
– Huge page利用可能 (2MB page)
• Topology
– CPUトポロジ (NUMA等)
– プロセッサ/メモリのaffinity
- 9. 9
Hyper Threadingの制御
• HVMならGRUBでCPUコア数を指定可能
• /etc/grub.confで指定
– grubby(8)で実行することも可能
– http://linux.die.net/man/8/grubby
# /sbin/grubby --update-kernel=ALL --args=maxcpus=18
# /sbin/shutdown -r now
$ cat /etc/grub.conf
default=0
timeout=0
title Red Hat Enterprise Linux Server (3.10.0-123.20.1.el7.x86_64) 7.0 (Maipo)
root (hd0)
kernel /boot/vmlinuz-3.10.0-123.20.1.el7.x86_64 ro root=UUID=668dbd02-c201-44bc-be76-
f606fc9ab8db console=hvc0 LANG=en_US.UTF-8 maxcpus=18
initrd /boot/initramfs-3.10.0-123.20.1.el7.x86_64.img
- 12. 12
Turbo Boost
• C3, i2, R2
– 全コアが同じようにブースト(ベース全体がクロックアップ)
• C4, D2 (Haswell Xeon)
– コア単位でステート制御が可能(P-State, C-State)
– カーネル 3.9以降で対応
– 並列拡張命令AVX2をヘビーに使うとコア側の周波数を落とす
ので注意
http://docs.aws.amazon.com/ja_jp/AWSEC2/latest/UserGuide/processor_state_control.html
- 14. 14
拡張ネットワーキング (Enhanced Networking)
• 拡張ネットワーキング
– パケット毎秒(PPS)が非常に大きく、
ネットワークレイテンシが低くな
るオプション。
– SR-IOV( Single Root IO
Virtualization)を使用
• 対応インスタンスタイプ
– C3, C4, R3, I2, D2
• 適応条件
– VPC内でHVM AMIで起動
– SR-IOVドライバ(ixgbevf 2.14.2
以降)が必要
– カーネル2.6.32以降
http://docs.aws.amazon.com/ja_jp/AWSEC2/latest/UserGuide/enhanced-networking.html
物理NIC
VMM
Host OS
NIC
Driver
PV
Driver
PV
Driver
H/W
EC2 (Guset OS)
物理NIC
VMM
Host OS
NIC
Driver(PF)
VF
Driver
H/W
EC2 (Guset OS)
VFPF
paravirtual
SR-IOV
VF
Driver
EC2 (Guset OS)
VF
VF: Virtual Function
PF: Physical Function
- 15. 15
続 : 拡張ネットワーキング (Enhanced Networking)
• Ixgbevfドライバ
– Intel 10 Giga Bit Ethernet Virtual Function
• http://sourceforge.net/projects/e1000/files/ixgbevf%20stable/
– VFはPCIデバイスとして見える。
– VMMやDom0を介さずに NICのVFを操作するためオーバーヘッド
が少ない
http://docs.aws.amazon.com/ja_jp/AWSEC2/latest/UserGuide/enhanced-networking.html
物理NIC
VMM
Host OS
NIC
Driver(PF)
VF
Driver
H/W
EC2 (Guset OS)
VFPF
SR-IOV
VF
Driver
EC2 (Guset OS)
VF
VF: Virtual Function
PF: Physical Function
- 16. 16
Placement Groups
• インスタンス間通信を最適化
– 広帯域 (最大10Gbps Full Bisection)
– 低レイテンシ
– 高PPS (packets per seconds)
• 用途
– HPC、Hadoop、MPP、DWHなど、ノード間通信
が大量に発生するクラスタに最適
– 拡張ネットワーキング(SR-IOV)との併用を推奨
• 制限
– 単一アベイラビリティゾーンに閉じる
– 利用可能なインスタンスタイプに制限あり。
Full bisection bandwidth
http://docs.aws.amazon.com/ja_jp/AWSEC2/latest/UserGuide/placement-groups.html
- 17. 17
もっとPPS(Packet per second)を増やすには
• 受信パケット処理がネックに
– パケット受信処理は受信キュー(RX)が一つ
– 割り込みが1コアに集中し、他のコアは遊んで
いる状態が発生
• 対策:
– 1インスタンスに複数のNIC (ENI)をつける
– 複数コアに受信パケットを振り分ける
• Receive Side Scaling (RSS)
• Receive Packet Steering (RPS)
• Receive Flow Steering(RFS)
https://access.redhat.com/documentation/ja-
JP/Red_Hat_Enterprise_Linux/6/html/Performance_Tuning_Guide/main-network.html
eth0
CPU0
core0 core1 core0 core1
packets
rx
CPU1
- 18. 18
続: もっとPPS(Packet per second)を増やすには
• RSS (Receive Side Scaling)
– H/W が持つ複数のキューを使う
– SR-IOVで可能(ENI1つで最大2個)
• RPS ( Receive Packet Steering)
– RSSのソフトウェア実装
– PVドライバでも設定可能
– RSSとの併用可能
• RFS (Receive Flow Steering)
– RPSの拡張
– CPUキャッシュの効率化が可能
– Numactl, taskset等も意識する
eth0
core0 core1 core0 core1
packets
rx0 rx1
Hash &
dispatch
eth0
core0 core1 core0 core1
packets
rx0 Hash &
dispatch
RSS
RPS
https://access.redhat.com/documentation/ja-JP/Red_Hat_Enterprise_Linux/6/html/Performance_Tuning_Guide/network-rss.html
https://access.redhat.com/documentation/ja-JP/Red_Hat_Enterprise_Linux/6/html/Performance_Tuning_Guide/network-rps.html
packets
rx0 rx1
Hash &
dispatch
eth1
CPU1CPU0
CPU0 CPU1
- 21. 21
SSDインスタンスディスク の高速化
• 高速なSSD
– i2, r3インスタンス
• カーネル3.8以降が性能面でお薦め
– Amazon Linux 13.09以降、RHEL7, Ubuntu14.04以降
– (※理由は次ページ)
• TRIM利用可能
– i2, r3対応
– # fstrim /dev/sdX
– (※SSD EBSは TRIM非対応)
http://docs.aws.amazon.com/ja_jp/AWSEC2/latest/UserGuide/InstanceStorage.html#Inst
anceStoreTrimSupport
- 22. 22
カーネル3.8.0前後のI/O性能の違い
• 3.8.0以前
– 全I/Oが I/Oドメインを通
る”Grant Mapping”
– TLB flushのコストが大きい
• 3.8.0以降
– Persistent Grantsパッチが
適用されている
– プール作成時に“Grant
Mapping”を一度行う
– データはGrant Poolにコ
ピーされる
– 再mappingに較べてコピー
は非常に速い
SSD
Dom0 I/Oドメイン Guest(インスタンス)
read(fd,buffer,BLOCK_SIZE)
Grant Mapping
Persistent Grants
SSD
read(fd,buffer,BLOCK_SIZE)
https://blog.xenproject.org/2012/11/23/improving-block-protocol-scalability-with-persistent-grants/
http://www.slideshare.net/xen_com_mgr/20140818-scaling-xens-aggregate-storage-performance
Dom0 I/Oドメイン Guest(インスタンス)
- 24. 24
まとめ
• Linuxカーネル
– 必要な性能と突き合わせる
• HVMを選ぶ
– SR-IOV化は必須
• CPU/メモリ
– HyperThreadingの有無を比較
– NUMAやCPU affinityにも注目
– Turbo Boostを計測して効果的に使う
• I/Oチューニング
– Linuxカーネル
– ENI
機能 カーネル
HMV 2.6.36+
SR-IOV 2.6.32+
RPS/RFS 2.6.35+
CPU State 3.9.0+
Grant
mapping
3.8.0+