k8s-prometheus-memory

芒果牛奶 2021-02-23 16:03:54
技术开发 memory Prometheus SegmentFault k8s-prometheus-memory


prometheus 内存


Node Exporter 有 251 个测量点
Prometheus 服务本身有 775 个测量点
sample_count(duration) = 节点数 * [ 测量点 * (duration / interval )]
例如:获取3h,100个节点,每个节点251个测量点,每隔15s,取一次样本,总共的样本数
duration = 3h
节点数 = 100
测量点 = 251
interval =15s
sample_count(3h) = 100 * [ 251 * (3*60*60 / 15)] = 18072000
由 Prometheus 的官方文档,使用 double-delta 方案对数据进行编码后,每条样本的字节大小为:sample_size=3.3B
Prometheus 对内存的使用由以下四个部分组成:
1、留存于内存的活跃样本
2、排队等待持久化的过期样本
3、索引数据
4、其他运行时内存消耗
3.1.1 留存于内存的活跃样本
假设我们要求的留存时间为 mem_retention,则所需的内存空间为:
sample_mem_1=sample_size * sample_count(mem_retention)
例如:
mem_retention = 6h
节点数 = 100
测量点 = 251
interval = 1s
sample_mem_1= sample_size * sample_count(mem_retention)
= 3.3B * sample_count(6h)
= 3.3B * 100 * [ 251 * (6*60*60 / 1)]
= 1789128000B /1000 /1000 /1000
= 1.789G
2、排队等待持久化的过期样本
为了完成对当前所有排队样本的持久化,Prometheus 需要花费的时间周期为 persist_cycle,一般情况下,持久化的时间周期为 6 个小时: persist_cycle=6h
为了不至于使 Prometheus 进入紧急模式(Rush mode),排队样本所占的空间不应超过预估空间的 80%
例如:
节点数 = 100
测量点 = 251
interval = 1s
因此,排队样本所需的内存空间为:
sample_mem_2 = [ sample_size * sample_count(persist_cycle)] / 0.8
= [ 3.3B * sample_count(6h) ] / 0.8
= 3.3B * 100 * [ 251 * (6*60*60 / 1)] / 0.8
= 1789128000B / 0.8
= 2236410000B /1000 /1000 /1000
= 2.2364G
3、索引数据
对索引数据所需内存的估计,可以使用下面的经验公式:
series_count= 节点数 * 测量点
index_mem=series_count / 1000 MB
版权声明
本文为[芒果牛奶]所创,转载请带上原文链接,感谢
https://segmentfault.com/a/1190000039262814

  1. Spring can still play like this! Ali's new spring product has successfully overturned my understanding of spring!
  2. IntelliJ idea can also draw mind maps. It's really the strongest ide!
  3. JavaScript performance optimization [inline cache] V8 engine features
  4. linux 配置java环境
  5. linux find 查找文件
  6. 深入理解 Web 协议 (三):HTTP 2
  7. IntelliJ IDEA 相关问题记录
  8. Deep understanding of Web protocol (3): http 2
  9. 深入理解 Web 协议 (三):HTTP 2
  10. 腾讯IEG开源AI SDK:自动化测试吃鸡、MOBA类游戏
  11. Mysql Command
  12. Configuring Java environment with Linux
  13. Find files in Linux
  14. docker-Dockerfile 创建镜像
  15. Redis Cluster
  16. 深入理解 Web 协议 (三):HTTP 2
  17. JavaScriptBOM操作
  18. JavaScriptBOM操作
  19. Deep understanding of Web protocol (3): http 2
  20. Record of IntelliJ idea related problems
  21. Deep understanding of Web protocol (3): http 2
  22. Tencent IEG open source AI SDK: automatic testing of chicken eating and MoBa games
  23. Mysql Command
  24. Docker dockerfile create image
  25. Redis Cluster
  26. 死磕Spring之IoC篇 - 文章导读
  27. Deep understanding of Web protocol (3): http 2
  28. JavaScript BOM operation
  29. JavaScript BOM operation
  30. 死磕Spring之IoC篇 - 文章导读
  31. k8s node 操作与维护
  32. k8s 证书更新
  33. 【Java面试题第三期】JVM中哪些地方会出现内存溢出?出现的原因是什么?
  34. HashMap连环问你能答出几道?
  35. k8s-cronjob
  36. k8s-cert
  37. 头条面试官:说说Kafka的消费者提交方式,怎么实现的
  38. 什么是HTTPS以及如何实施HTTPS?
  39. Spring: an introduction to IOC
  40. Spring: an introduction to IOC
  41. Operation and maintenance of k8s node
  42. K8s certificate update
  43. vue使用sdk进行七牛上传
  44. k8s-dns
  45. JavaScript 邮箱验证 - 正则验证
  46. k8s-dashboard
  47. HashMap连环问你能答出几道?
  48. Where does memory overflow occur in the JVM? What are the reasons for this?
  49. How many questions can you answer?
  50. k8s-cronjob
  51. spring注解--Transactional
  52. k8s-cert
  53. Will the Spring Festival holiday be extended to February 27 in 2021? Here comes the response
  54. Headline Interviewer: talk about Kafka's consumer submission method, how to achieve it
  55. 【k8s集群】搭建步骤
  56. k8s-kubeadm
  57. k8s-etcd
  58. What is HTTPS and how to implement it?
  59. Java中使用HashMap改进查找性能
  60. maven发布jar包运行时找不到类问题