【问题标题】:How to check the number of workers running inside a docker container of kubernetes pod?如何检查在 Kubernetes pod 的 docker 容器中运行的工人数量?
【发布时间】:2020-09-04 09:36:15
【问题描述】:

我将 Flask-uWSGI 架构用于生产服务,并将 uWSGI 配置的 master 标志设置为 False。在运行服务时,我将 NUM_WORKERS 的 uWSGI 作为2 传递给 docker 容器。基于此doc on uWSGI configmaster 标志是重新生成和预分叉工人所必需的。我想知道我的 pod 中的服务容器是否实际上使用了 2 个工作人员?

所以,我想exec 进入一个 pod 并查看实际使用的 uWSGI 工作人员的数量?

不相关,但我的 uWSGI 配置:

[uwsgi]
socket = 0.0.0.0:9999
protocol = http
module = my_app.server.wsgi
callable = app
master = false
thunder-lock = true

【问题讨论】:

    标签: docker flask kubernetes uwsgi


    【解决方案1】:

    将 prometheus-exporter 添加到您的应用程序,并手动 curl /metrics 端点: https://github.com/timonwong/uwsgi_exporter

    它有 num 个工人指标:https://github.com/timonwong/uwsgi_exporter/blob/9f88775cc1a600e4038bb1eae5edfdf38f023dc4/exporter/exporter.go#L50

    此外,您可以使用 Prometheus 收集此信息以自动监控和警报。

    【讨论】:

    • 我已经为我的应用设置了 prometheus,它有一些延迟和日志相关的指标。
    • 然后尝试 exec 和 curl http://127.0.0.1/metrics | grep workers
    猜你喜欢
    • 2015-08-18
    • 1970-01-01
    • 2022-11-30
    • 2020-05-12
    • 1970-01-01
    • 2020-05-13
    • 2018-10-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多