Share
Embed
過去事例から見るモニタリングの大切さ #techfeed_live
どんなに著名なOSSであっても、利用法によってはパフォーマンスチューニングが必要になる場面が存在します。 今回は過去に体験した事例から、モニタリングの大切さについてご紹介します。
Talked by TechFeed Experts Night#20 〜 Webパフォーマンス・チューニング最前線 : 前編(概要、モニタリング、負荷テスト編)
Transcript
49 slides
-
過去事例から⾒るモニタリングの⼤切さ 株式会社サイバーエージェント CIU Development div Nakanishi Kento @whywaita TechFeed
Experts Night# 20 #techfeed_live Webパフォーマンス‧チューニング最前線 : 前編 (概要、モニタリング、負荷テスト編)@ 2023/06/07 -
Nakanishi Kento / whywaita • 株式会社サイバーエージェント 2019〜 • 業務: CAグループ向けプライベートクラウド開発
• IaaS の開発 / CIサービス (myshoes) の開発 • ISUCON 8 優勝 (学⽣) • ISUCON 10 運営 (インフラ提供) • 趣味: ポーカー / XREAL Air / ⾃宅インフラ -
Cycloud 7 •Cy(berAgent)cloud •各種サービスの提供 •IaaS / KaaS / PaaS /
ML Platform •Cycloud-hosted runner (myshoes) -
プライベートクラウド概要図 13 L 2 Overlay Network (VXLAN on IP CLOS)
Compute Node Compute Node Compute Node k 8 s master k 8 s master Firewall Load Blancer KVM / Container Users VM Users VM Users Service nova neutron Container KVM / Container OpenStack Controller Container other Container User Components OpenStack Components Physical Components Storage -
プライベートクラウド (OpenStack) の展開 14 L 2 Compute Node Compute Node
Compute Node k master k k Storage Storage KVM / Container Users VM Users VM Users Service nova KVM / Container OpenStack other User Components OpenStack Physical 我々が提供するのはユーザ向けのVM -
プライベートクラウド (OpenStack) の展開 15 L 2 Compute Node Compute Node
Compute Node k master k k Storage Storage KVM / Container Users VM Users VM Users Service nova KVM / Container OpenStack other User Components OpenStack Physical VM⽤のストレージは ネットワークごしにマウント -
プライベートクラウド概要図 16 L 2 Compute Node Compute Node Compute Node
k master k Firewall Load KVM / Container Users Users Users nova neutron Container KVM / Container OpenStack Controller Container other Container User OpenStack Components Physical Storage プロセスがたくさんあります! -
プライベートクラウド概要図 17 L 2 Overlay Network (VXLAN on IP CLOS)
Compute Node Compute Node Compute Node k 8 s master k 8 s master Firewall Load Blancer KVM / Container Users VM Users VM Users Service nova neutron Container KVM / Container OpenStack Controller Container other Container User Components OpenStack Components Physical Components Storage Compute Node Compute Node Compute Node k 8 s master k 8 s master Firewall Load Blancer Storage Compute Node Compute Node Compute Node k 8 s master k 8 s master Firewall Load Blancer Storage Compute Node Compute Node Compute Node k 8 s master k 8 s master Firewall Load Blancer Storage Compute Node Compute Node Compute Node k 8 s master k 8 s master Firewall Load Blancer Storage Compute Node Compute Node Compute Node k 8 s master k 8 s master Firewall Load Blancer Storage -
プライベートクラウド概要図 18 L 2 Overlay Network (VXLAN on IP CLOS)
Compute Node Compute Node Compute Node k 8 s master k 8 s master Firewall Load Blancer KVM / Container Users VM Users VM Users Service nova neutron Container KVM / Container OpenStack Controller Container other Container User Components OpenStack Components Physical Components Storage Compute Node Compute Node Compute Node k 8 s master k 8 s master Firewall Load Blancer Storage Compute Node Compute Node Compute Node k 8 s master k 8 s master Firewall Load Blancer Storage Compute Node Compute Node Compute Node k 8 s master k 8 s master Firewall Load Blancer Storage Compute Node Compute Node Compute Node k 8 s master k 8 s master Firewall Load Blancer Storage Compute Node Compute Node Compute Node k 8 s master k 8 s master Firewall Load Blancer Storage nova neutron Container OpenStack Controller Container other Container nova neutron Container OpenStack Controller Container other Container nova neutron Container OpenStack Controller Container other Container nova neutron Container OpenStack Controller Container other Container nova neutron Container OpenStack Controller Container other Container -
20 $ kubectl get nodes | grep ^cn cn0001 Ready
cn,node cn0002 Ready cn,node cn0003 Ready cn,node cn0004 Ready cn,node -
プライベートクラウド概要図 21 L 2 Compute Node Compute Node Compute Node
k master k k Storage Storage KVM / Container Users Users Users nova neutron Container KVM / Container OpenStack other User OpenStack Components Physical Components OpenStack⽤のコンポーネントは Podとして管理 -
22 $ kubectl get pod -n openstack -o wide |
grep nova-api nova-api-849dff6d5b-68z8h 2/2 Running 0 22d x.x.x.x k8smaster01 nova-api-849dff6d5b-8d95z 2/2 Running 0 22d x.x.x.x k8smaster02 nova-api-849dff6d5b-bp64w 2/2 Running 0 22d x.x.x.x k8smaster03 nova-api-849dff6d5b-cxhwt 2/2 Running 0 22d x.x.x.x k8smaster04 複数ノードに渡るプロセスを ⼀括管理可能! -
CPU利⽤率が⾼いとは? →ISUCON本 9章 (p 243 ) PromQL 100 -
avg by (host, cpu) (rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100 28 -
33 libcontainer (*Handler).GetStats ↓ fs (*Handler).GetStats ↓ fs (*BlkioGroup).GetStats
↓ fs getBlkioStat ↓ bu fi o (*Scanner).Scan ↓ Poll (*FD).Read ↓ syscall Syscall -
GetStats ? 34 • Kubernetes (kubelet含)に組み込まれている メトリクス出⼒機能関連の関数だと観測できる • https://kubernetes.io/docs/concepts/cluster-administration/
system-metrics/ • google/cadvisor (の内部処理)を⽤いてメトリクス取得を⾏ってい る • ⼤元は google/cadvisor/manager (*containerData).housekeeping -
kubeletはどうやってメトリクスを取得しているか 35 • cgroupfs を使ってメトリクスを取得してそう • 今回は /sys/fs/cgroups にマウント •
cgroup: コントロールグループ • リソースの割当 / 調整を実現する機能 Linux Kernelが提供 • コンテナの状況‧ホストの状況などをメトリクス化 -
iovisor/bcc/opensnoop 38 https://github.com/iovisor/bcc/blob/ a 078 cbc 7 cfbdcee 8 8
c 9 cf 3 e 2 b 76 c 2 c 8 c 1 51 7 e 47 8 /tools/opensnoop_example.txt より # ./opensnoop PID COMM FD ERR PATH 17326 <...> 7 0 /sys/kernel/debug/tracing/trace_pipe 1576 snmpd 9 0 /proc/net/dev 1576 snmpd 11 0 /proc/net/if_inet6 1576 snmpd 11 0 /proc/sys/net/ipv4/neigh/eth0/retrans_time_ms 1576 snmpd 11 0 /proc/sys/net/ipv6/neigh/eth0/retrans_time_ms 1576 snmpd 11 0 /proc/sys/net/ipv6/conf/eth0/forwarding 1576 snmpd 11 0 /proc/sys/net/ipv6/neigh/eth0/base_reachable_time_ms 1576 snmpd 11 0 /proc/sys/net/ipv4/neigh/lo/retrans_time_ms 1576 snmpd 11 0 /proc/sys/net/ipv6/neigh/lo/retrans_time_ms -
iovisor/bcc/opensnoop 39 https://github.com/iovisor/bcc/blob/ a 078 cbc 7 cfbdcee 8 8
c 9 cf 3 e 2 b 76 c 2 c 8 c 1 51 7 e 47 8 /tools/opensnoop_example.txt より # ./opensnoop -e -f O_WRONLY -f O_RDWR PID COMM FD ERR FLAGS PATH 28084 clear_console 3 0 00100002 /dev/tty 28084 clear_console -1 13 00100002 /dev/tty0 28084 clear_console -1 13 00100001 /dev/tty0 28084 clear_console -1 13 00100002 /dev/console -
iovisor/bcc/opensnoop 40 https://github.com/iovisor/bcc/blob/ a 078 cbc 7 cfbdcee 8 8
c 9 cf 3 e 2 b 76 c 2 c 8 c 1 51 7 e 47 8 /tools/opensnoop_example.txt より ./opensnoop -Tp 1956 TIME(s) PID COMM FD ERR PATH 0.000000000 1956 supervise 9 0 supervise/status.new 0.000289999 1956 supervise 9 0 supervise/status.new 1.023068000 1956 supervise 9 0 supervise/status.new 1.023381997 1956 supervise 9 0 supervise/status.new 2.046030000 1956 supervise 9 0 supervise/status.new 2.046363000 1956 supervise 9 0 supervise/status.new -
調査 41 • opensnoopによりopenファイルが分かっ たので、どのファイルが⼤きいのか調査 $ cat snoop.log |
awk '{print $8}' | xargs -I%% bash -c "echo %%; time cat %%" -
発⾒ 42 /sys/fs/cgroup/blkio/blkio.throttle.io_serviced: real 0m3.599s /sys/fs/cgroup/blkio/blkio.throttle.io_service_bytes: real 0m4.455s $ cat
/sys/fs/cgroup/blkio/blkio.throttle.io_serviced | wc -l 2071 "νϣίͨͬΓʂ -
blkio.throttle.io_serviced とは 43 • Number of bytes transferred to/from the
disk by the group. These are further divided by the type of operation - read or write, sync or async. First two fi elds specify the major and minor number of the device, third fi eld speci fi es the operation type and the fourth fi eld speci fi es the number of bytes. • https://github.com/torvalds/linux/blob/a 4 d 7 d 7 011 21 981 e 3 c 3 fe 6 9 ade 3 7 6 fe 9 f 2 6324 1 61 / Documentation/admin-guide/cgroup-v 1 /blkio-controller.rst より引⽤ • ざっくり⾔うと: ディスクとの転送量 -
[再掲] プライベートクラウド (OpenStack) の展開 45 L 2 Compute Node Compute
Node Compute Node k master k k Storage Storage KVM / Container Users VM Users VM Users Service nova KVM / Container OpenStack other User Components OpenStack Physical VM⽤のストレージは ネットワークごしにマウント -
問題発覚 47 • ハイパーバイザはVM起動⽤に多くのディスクが接続さ れている ( /dev/sdca なども頻出) • kubeletはホスト上のメトリクスを無邪気に取得する
• ディスクが多い & ネットワーク的要因で cgroup 経由の 情報取得がかなり遅延 → kubelet の処理時間が⻑くCPU利⽤率の増加!!!! 😇 -
ちなみに 48 Opened this issue on May 3 1 ,
20 16 😇 https://github.com/opencontainers/runc/issues/ 8 61