【问题标题】:Multi Workers Sanic App And pyformance Lib for Metrics Reporting用于指标报告的多工人 Sanic 应用程序和性能库
【发布时间】:2018-07-28 09:19:30
【问题描述】:

我正在尝试使用 pyformance metrics library 将指标添加到 sanic based 应用程序。

import random
import time

from sanic import Sanic
from sanic.response import json

from pyformance import MetricsRegistry
from pyformance.reporters.carbon_reporter import CarbonReporter

registry = MetricsRegistry()
__reporter__ = CarbonReporter(registry=registry,
                          reporting_interval=10,
                          prefix='sanic',
                          server='localhost',
                          port=2003)
__reporter__.start()
app = Sanic()

@app.route("/api/v1/foo", methods=["POST"])
   def foo(request):

      timer = registry.timer(".foo")
         with timer.time():
         time.sleep(random.randint(1, 2))
         return json({"status": True})

if __name__ == "__main__":
     app.run(host='0.0.0.0', port=8080, workers=1, access_log=False, 
     debug=False)

当运行 1 个 worker 时一切看起来都很好,但是当配置更多 worker 时,没有指标被发送到 carbon。

感谢任何帮助,以及从多工人 sanic 应用程序向石墨发送指标的不同方法。

【问题讨论】:

    标签: python-3.x graphite-carbon sanic


    【解决方案1】:

    所以多个工作人员基本上会对工作人员进行子处理,可能是 IPC 回到主进程。

    尝试根据这个运行多个worker,看看是否仍然存在相同的行为? How to configure ExecStart for Gunicorn without WSGI?

    gunicorn 在这里管理流程。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-16
      相关资源
      最近更新 更多