Ceph RBD:perfcounter + prometheus性能统计

引言

Perfcounter是在RBD IO处理过程中进行的性能统计,以累加的方式进行,包括IO数量、总计时延、总计带宽等,用户可根据计算得到某一时间段内的IOPS、平郡时延、平均带宽等性能统计数据,这些数据可用户性能展示或性能问题定位。

本文主要结论

本文基于Ceph N版本进行说明。

  • RBD的性能统计可以分为两类
    • 基于OSD的性能统计(见rbd perf image iotop命令):基于OSD的性能统计,将其在每个image上进行累加得到。
    • 基于RBD client的性能统计(本文介绍的perfcounter):在每个rbd image open时,使用一个内存空间,记录此image的性能统计信息。
  • 统计流程
    • Perfcounter注册(librbd使用者执行):在rbd_open流程中send_refresh注册perfcounter性能统计。
    • Daemon注册(librbd使用者执行):调用rados_service_register接口向ceph-mgr注册一个daemon服务。
    • Perfcounter统计计数:rbd在处理image读写请求的过程中会累加perfcounter点。
    • Ceph-Mgr性能采集:配置文件更新后,ceph-mgr会启动一个定时器,周期采集perfcounter数据。
    • Prometheus性能采集:在查询的时候会遍历ceph-mgr所有注册的daemon,然后调用get_perf_schema查询对应的perfcounter的性能数据,并通过matrix上报。

代码解读

下文主要基于代码流程进行介绍。

Perfcounter注册

在rbd_open流程中进行perfcounter注册。

librbd::image::OpenRequest<librbd::ImageCtx>::handle_v2_get_data_pool
	librbd::image::OpenRequest<librbd::ImageCtx>::send_refresh
		librbd::ImageCtx::init
			librbd::ImageCtx::perf_start
				perfcounter = plb.create_perf_counters();
					cct->get_perfcounters_collection()->add(perfcounter);

Daemon注册

RBD client的使用者在rbd_open之后,需要向ceph-mgr注册daemon,才能正常通过promethues进行统计。
1、RBD client发送端

rados_service_register
	_rados_service_register
		librados::RadosClient::service_daemon_register
			MgrClient::service_daemon_register
				MgrClient::_send_open
					auto open = new MMgrOpen
					session->con->send_message(open)

2、Ceph-mgr接收端处理

DispatchQueue::DispatchThread::entry
	DispatchQueue::entry
		ms_deliver_dispatch
			Dispatcher::ms_dispatch2
				DaemonServer::ms_dispatch
					DaemonServer::handle_open
						DaemonStateIndex::insert
							DaemonStateIndex::_insert
								by_server[dm->hostname][dm->key] = dm

Perfcounter统计计数

RBD在IO处理过程中进行计数统计。可以搜索相关的性能统计点,找到性能统计位置,如点位l_librbd_rd和l_librbd_rd_bytes

ImageReadRequest<I>::send_request
	image_ctx.perfcounter->inc(l_librbd_rd);
	image_ctx.perfcounter->inc(l_librbd_rd_bytes, buffer_ofs);

Ceph-Mgr性能采集

在ceph-mgr检测到配置变更后,会启动一个定时器,周期采集perfcounter数据,并发送给ceph-mgr master。
1、发送端

MgrClient::handle_mgr_configure
	MgrClient::_send_stats
		MgrClient::_send_report
		SafeTimer::add_event_after // 启动定时器

2、接收端

DaemonServer::ms_dispatch
	DaemonServer::handle_report
		DaemonPerfCounters::update

Prometheus性能采集

在查询的时候会遍历ceph-mgr所有注册的daemon,然后调用get_perf_schema查询对应的perfcounter的性能数据,并通过matrix上报。

MetricCollectionThread::collect // 线程定时获取,存放在inst.collect_cache = data中
	collect
		get_all_perf_counters
			list_servers
				_ceph_get_server
					ceph_get_server
						ActivePyModules::list_servers_python
							with_daemons_by_server // 此处会遍历上的by_server
			get_perf_schema // 获取统计数据
				get_perf_schema_python
					DaemonStateIndex::get

参考文献

https://github.com/ceph/ceph

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值