Go问答 监控系统中到底是 pull 还是 push 方案好?

astaxie · 2016年11月14日 · 最后由 UlricQin 回复于 2020年03月22日 · 1338 次阅读

最近在研究各种监控系统,但是发现 push 和 pull 的方案都有,我也不知道这个里面到底哪个方案比较好?大家说说两个的利弊?


Push Pull
Discovery Agent automatically sends metrics as soon as it starts up, ensuring that it is immediately detected and continuously monitored. Speed of discovery is independent of number of agents.
Scalability Polling task fully distributed among agents, resulting in linear scalability. Lightweight central collector listens for updates and stores measurements. Minimal work for agents to periodically send fixed set of measurements. Agents are stateless, exporting data as soon as it is generated.
Security Push agents are inherently secure against remote attacks since they do not listen for network connections.
Operational Complexity Minimal configuration required for agents: polling interval and address of collector. Firewalls need to be configured for unidirectional communication of measurements from agents to collector.
Latency The low overhead and distributed nature of the push model permits measurement to be sent more frequently, allowing the management system to quickly react to changes. In addition, many push protocols, like sFlow, are implemented on top of UDP, providing non-blocking, low-latency transport of measurements.
Flexibility Relatively inflexible: pre-determined, fixed set of measurements are periodically exported.
  • 加微信实战群请加微信(注明:实战群):gocnio


pull 和 push 最本质的区别是啥呢?

如果处理系统来得及处理就 push,反之 pull

方案选择没有统一的标准,参照上面的有缺对比,根据自己的项目需求、自己公司的体量、能够分配的资源统一做决定吧。 通常来说 push 的方案实现起来比较简单,起码不用考虑 discovery 的事。

  • 调研过好几个方案使用的都是 push,如 Scout/Datadog。
  • 我使用的是 prometheus 使用的是 pull 方式。

之前我们公司用的是主动 push 模式

pull 方式缺点

  • 不好设置 timeout,太长不合适,太短不合适
  • 目标太多的话服务端随机端口不够用
  • 需要有个注册中心,这样才知道去哪里 pull

夜莺采用 push 模型,就是因为 pull 模型的这几个缺点

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册