Upgrade to Pro — share decks privately, control downloads, hide ads and more …

[Prometheus Meetup#3] Victoria Metricsで作りあげる大規模・超負荷システムモニタリング基盤 / Monitoring Platform With Victoria Metrics

[Prometheus Meetup#3] Victoria Metricsで作りあげる大規模・超負荷システムモニタリング基盤 / Monitoring Platform With Victoria Metrics

inletorder

January 15, 2020
Tweet

Other Decks in Programming

Transcript

  1. 3 第 9 回 Google Cloud INSIDE Games & Apps

    GKEとCloud Spannerが躍動するドラゴンクエストウォーク 告知: 最近の発表 https://www.slideshare.net/GoogleCloudPlatformJP/gke-cloud-spanner-9-google-cloud-inside-game-apps
  2. 4 アジェンダ • 前提・背景 • 3rd-party Storage検討 • Victoria Metricsとは?

    • なぜVictoriaMetricsを選んだのか? • Parameter Tuning • その他の工夫 • まとめ
  3. 21 Thanos 出典: https://github.com/thanos-io/thanos ThanosはImprobable社が開発を行っている CNCFでホストされているプロダクトです。 【負荷試験当時の問題点】 Grafanaでモニタリング ↓ 直近データのQueryは

    Prometheusにも行く ↓ Remote Read API問題※により Prometheusのメモリ逼迫 ↓ Prometheus OOMKill Thanos Queryから参 照あり
 通常の2倍近くメモリ消費
  4. 22 Appendix) Thanos Remote Read API問題(> v2.13.0) 2.13.0以前はStreaming非対応 ↓ Prometheus,

    Thanos Sidecar の両方にqueryのresponse がメモリに展開される ↓ 2倍のメモリ必要 出典: https://prometheus.io/blog/2019/10/10/remote-read-meets-streaming TSDB Server Thanos Sidecar
  5. 23 Appendix) Thanos Remote Read API問題(> v2.13.0) 出典: https://prometheus.io/blog/2019/10/10/remote-read-meets-streaming TSDB

    Prometheus Thanos Sidecar Thanos Query ①. Thanos QueryからのrequestはThanos Sidecarを 通してPrometheusへ送られる ①
  6. 24 Appendix) Thanos Remote Read API問題(> v2.13.0) 出典: https://prometheus.io/blog/2019/10/10/remote-read-meets-streaming TSDB

    Prometheus Thanos Sidecar Thanos Query ②. TSDBからmetricsをselect   ↓ Prometheus内で結果をすべてメモリに展開してから responseとしてThanos Sidecarに渡し 最終的にThanos Queryへ返す ②
  7. 25 Appendix) Thanos Remote Read API問題(> v2.13.0) 出典: https://prometheus.io/blog/2019/10/10/remote-read-meets-streaming TSDB

    Prometheus Thanos Sidecar Thanos Query ②. TSDBからmetricsをselect   ↓ Prometheus内で結果をすべてメモリに展開してから responseとしてThanos Sidecarに渡し 最終的にThanos Queryへ返す ② Memoryを2倍使用!!
  8. 26 Appendix) Thanos Remote Read API問題(<= v2.13.0) Streaming対応 出典: https://prometheus.io/blog/2019/10/10/remote-read-meets-streaming

    TSDB Prometheus Thanos Sidecar Thanos Query ①. Thanos QueryからのrequestはThanos Sidecarを 通してPrometheusへ送られる ①
  9. 27 Appendix) Thanos Remote Read API問題(<= v2.13.0) Streaming対応 出典: https://prometheus.io/blog/2019/10/10/remote-read-meets-streaming

    TSDB Prometheus Thanos Sidecar Thanos Query ②. TSDBからmetricsをselect   ↓ 結果の一部をメモリに展開してから チャンクレスポンスとしてThanos Sidecarに渡し 順次Thanos Queryへ返す ②
  10. 28 Appendix) Thanos Remote Read API問題(<= v2.13.0) Streaming対応 出典: https://prometheus.io/blog/2019/10/10/remote-read-meets-streaming

    TSDB Prometheus Thanos Sidecar Thanos Query ②. TSDBからmetricsをselect   ↓ 結果の一部をメモリに展開してから チャンクレスポンスとしてThanos Sidecarに渡し 順次Thanos Queryへ返す ② Memory効率 劇的に改善
  11. 29 M3DB M3DBはPrometheusのスケール問題を 解決するためにUberが開発した Remote Writeのプロダクトです。 etcdクラスタを組んだ上で、 M3DBをOperatorやHelm Chartで 構築していきます

    【負荷試験当時の問題点】 ・構築、管理コスト高い ・Namespaces, Shards等の固有の   概念もあり学習コスト高い 出典: https://static.sched.com/hosted_files/kccnceu19/e0/M3%20and%20Prometheus% 2C%20Monitoring%20at%20Planet%20Scale%20for%20Everyone.pdf
  12. 33 Victoria Metrics Victoria Metrics is ... THE BEST LONG-TERM

    REMOTE STORAGE FOR PROMETHEUS 公式ページ: https://victoriametrics.com/ Features ・SIMPLIFIES MONITORING ・GLOBAL QUERY VIEW ・DESIGNED TO BE FAST ・NATIVE PROMQL SUPPORT ・LONG TERM STORAGE ・LOW RESOURCE USAGE 本番運用から数ヶ月経ちましたが、非常に高い信頼性で動作しています
  13. 34 Architecture 【Mode】 Single version Cluster version の2種あります 右図はCluster ver

    の図になります 出典: https://github.com/Victoria Metrics/VictoriaMetrics/blo b/cluster/README.md
  14. 36 Architecture - VMSelect VMSelect storageに対して Queryを発行する Grafanaの Datasourceには VMSelectのLBを

    指定する 出典: https://github.com/Victoria Metrics/VictoriaMetrics/blo b/cluster/README.md
  15. 37 Architecture - VMInsert VMInsert storageに対して Writeを担当 Prometheusの RemoteWriteには VMInsertのLBを

    指定する 出典: https://github.com/Victoria Metrics/VictoriaMetrics/blo b/cluster/README.md
  16. 39 Scale-out可能な仕組み A B metric名 Index A 0→2 B 1→0

    A B VMStorage: 3 VMInsert: 1 VMSelect: 1 Consistent hashing
  17. 40 Scale-out可能な仕組み A B metric名 Index A 2 B 0

    A B VMStorage: 3 VMInsert: 1 VMSelect: 1 すべてのVMStorageに 同じQueryを発行 Consistent hashing
  18. 47 Victoria Metricsを選んだ理由 • Simplicity Select, Insert, Storageの3要素のみ • Scalability

    Scale-inはできないものの、Scale-outは簡単にできる • Reliability 高い信頼性。リソース効率がよく、負荷試験や   本番リリース後もホストエラー以外では落ちることなく稼働
  19. 50 Prometheus remote_write設定 queue_config: max_shards: 30 capacity: 20,000 max_samples_per_send: 10,000

    ↓ • 最大 600,000 samples キューイング • Capacityサイズの半分溜まったらRemote Storageへ転送 Parameter Tuning 400k+ samples per second
  20. 52 Prometheus remote_write設定 Shards: WALからRemote Storageへ送るときに 一時的にSampleを格納する Appendix) Parameter Tuning

    shard0 shard1 . . . Dynamic Queues write-ahead log (WAL) Remote Storage スクレイピング量に応じ 動的に変化 shard2
  21. 56 Victoria Metrics VMSelect • maxConcurrentRequests: 2*vCPU 同時Request数はコア数の2倍までが推奨 • maxUniqueTimeseries:

    1,000,000 (default: 300,000) Parameter Tuning cannot find tag filter matching less than 300001 time series; either increase -search.maxUniqueTimeseries or use more specific tag filters
 天井にあたったParameter名が表示されるので Logベースでチューニングするのが簡単です
  22. 58 Prometheus& Victoria Metrics専用の NodePool(Node Instance Group)を用意 Scheduling上の工夫 Kubernetes cluster

    backend pool ZoneA ZoneB Instance Group label: back taint: back Instance Group label: back taint: back app pool ZoneA ZoneB Instance Group label: app taint: app Instance Group label: app taint: app prometheus pool ZoneA ZoneB Instance Group label: prom taint: prom Instance Group label: prom taint: prom system pool ZoneA ZoneB Instance Group label: system taint: system Instance Group label: system taint: system
  23. 59 収集Metricsが増えすぎて、kube-state-metricsがOOMKilled → kube-state-metrics専用のNodeを確保 Scheduling上の工夫 Kubernetes cluster backend pool ZoneA

    ZoneB Instance Group label: back taint: back Instance Group label: back taint: back app pool ZoneA ZoneB Instance Group label: app taint: app Instance Group label: app taint: app kube-state-metrics pool ZoneA ZoneB Instance Group label: metric taint: metric Instance Group label: metric taint: metric prometheus pool ZoneA ZoneB Instance Group label: prom taint: prom Instance Group label: prom taint: prom