如何衡量Mesos中每个容器的CPU利用率? [英] How to measure the CPU utilization of Each container in Mesos?

查看:129
本文介绍了如何衡量Mesos中每个容器的CPU利用率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有许多应用程序在Mesos的容器中运行,这些应用程序是通过马拉松管理的.我通过马拉松式(1,.5等)进行部署时为每个应用程序分配了CPU分配. 但是马拉松中的CPU分配,并不意味着其1个CPU或一半的CPU.它仅表示其时间共享比率.同样,每个容器都可以访问其主机上的所有CPU.

I have many apps running on containers in Mesos, managed via marathon. I have given CPU allocation for each app while deploying via marathon like 1, .5 etc. But the CPU allocation in marathon, does not mean that its 1 CPU or half CPU. It simply means that its time sharing ratio. Also each container gets to access all the CPUs on its Host.

现在,我想测量Mesos从站上每个Container的CPU效率,以便可以减少或增加Marathon中每个App的CPU分配.我只是想提高资源利用率.

Now, I want to measure the CPU efficiency of each Container on Mesos slaves, so that I can reduce or increase the CPU allocation in for each App in Marathon. I just want to make resource utilisation even more efficient.

我可以使用 https://github.com/bobrik/collectd-mesos-tasks,但是问题是CPU利用率指标与Marathon中的CPU分配无关.

I could use https://github.com/bobrik/collectd-mesos-tasks, but the problem is CPU utilisation metrics does not relate to the CPU allocation in Marathon.

推荐答案

在Mesos WebUI中,您可以看到执行器使用了多少CPU

In Mesos WebUI you can see how much CPU is used by your executor

此处是从 /monitor/statistics 端点并计算CPU使用率.

Here is the code that collects statistics from /monitor/statistics endpoint and calculate CPU usage.

您对cpus_total_usage感兴趣,因此以下方法应该对您有效

You are interested in cpus_total_usage so the following method should works for you

让我们假设ab是某个时间点的统计信息快照.要计算cpus_total_usage,我们需要计算执行程序在系统和用户空间中所花费的时间,并将其除以ab之间的时间.

Let's assume a and b are snapshot of statistics at some point in time. To calculate cpus_total_usage, we need calculate the time executor spent in the system and user space and divide it by the time elapsed between a and b.

cpus_total_usage = (
                    (b.cpus_system_time_secs - a.cpus_system_time_secs) +
                    (b.cpus_user_time_secs - a.cpus_user_time_secs)) / 
                    (b.timestamp - a.timestamp)
                   )
cpu_percent      = cpus_total_usage / cpu_limit * 100%

这篇关于如何衡量Mesos中每个容器的CPU利用率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆