性能测试工具 Application Performance Management 工具之 pinpoint

胡刚 · 2016年04月02日 · 最后由 zyb 回复于 2016年04月12日 · 3307 次阅读
本帖已被设为精华帖!

1.背景知识

Application Performance Management 是什么?

维基百科:

In the fields of information technology and systems management, Application Performance Management (APM) is the monitoring and management of performance and availability of software applications. APM strives to detect and diagnose complex application performance problems to maintain an expected level of service. APM is "the translation of IT metrics into business meaning ([i.e.] value)."

APM 监控和管理软件应用的性能和可用性,探测和诊断复杂的应用性能问题。

APM 理论框架:

这里写图片描述

APM 的鼻祖是 Google Dapper

英文版 paper: http://research.google.com/pubs/pub36356.html

中文翻译版: http://bigbully.github.io/Dapper-translation/

国外工具列表:

ZIPKIN: https://github.com/openzipkin/zipkin

pinpoint:https://github.com/naver/pinpoint

appdash: https://github.com/sourcegraph/appdash

国内工具列表:

阿里的鹰眼介绍: http://club.alibabatech.org/resource_detail.htm?topicId=102

点评的 cat: https://github.com/dianping/cat

京东的 hydra(不维护): https://github.com/odenny/hydra

还有个商业化的 oneAPM。

本文以 naver 的 pinpoint 为例,搭建一套自己的 APM 平台。

2.pinpoint 介绍

Pinpoint provides a solution to help analyze the overall structure of the system and how components within them are interconnected by tracing transactions across distributed applications.

Install agents without changing a single line of code

Minimal impact on performance (approximately 3% increase in resource usage)

Pinpoint 能帮助分析整个系统架构,在分布式应用中通过追踪事务解释系统组件间是怎么进行连接的。

Pinpoint 架构图:

这里写图片描述

Pinpoint 由 4 部分组成:

1.Pinpoint Agent, 2. Pinpoint Collector, 3. HBase, 4.Pinpoint Web UI

其中 2,4 必须启 web 容器。

Pinpoint 使用了字节码增强技术,在类加载时,注入到观察的应用 Class 文件中。

所以在启动应用时,必须设置-javaagent 为 Pinpoint 的 agent。

目前 Pinpoint 支持的模块:

JDK 6+

Tomcat 6/7/8, Jetty 8/9

Spring, Spring Boot

Apache HTTP Client 3.x/4.x, JDK HttpConnector, GoogleHttpClient, OkHttpClient, NingAsyncHttpClient

Thrift Client, Thrift Service

MySQL, Oracle, MSSQL, CUBRID, DBCP, POSTGRESQL

Arcus, Memcached, Redis

iBATIS, MyBatis

gson, Jackson, Json Lib

log4j, Logback

3.安装 Pinpoint

因为 Pinpoint 依赖 JDK6,7,8; 所以必须配置 JDK6,7,8 环境变量

在/etc/profile 添加:

JAVA_6_HOME="/data1/hugang/jdk1.6.0_45"
export JAVA_6_HOME
JAVA_7_HOME="/usr/local/jdk"
export JAVA_7_HOME
JAVA_8_HOME="/data1/hugang/jdk1.8.0_71"
export JAVA_8_HOME

#source /etc/profile

拷贝工程:

# git clone https://github.com/naver/pinpoint.git


本地安装:

# mvn install -Dmaven.test.skip=true

安装期间报错

报错info:

[ERROR] /data3/pinpoint/pinpoint-1.5.1/commons-hbase/src/main/java/com/navercorp/pinpoint/common/hbase/HbaseTemplate2.java:[303,22] error: cannot access CellScannable
[ERROR] /data3/pinpoint/pinpoint-1.5.1/commons-hbase/src/main/java/com/navercorp/pinpoint/common/hbase/PooledHTableFactory.java:[82,29] error: cannot access TableName


解决办法:

mvn install:install-file -Dfile=/data3/pinpoint/pinpoint-master/lib/zookeeper-3.4.5-cdh5.4.0.jar -DgroupId=org.apache.zookeeper -DartifactId=zookeeper -Dversion=3.4.5-cdh5.4.0 -Dpackaging=jar -DcreateChecksum=true

mvn install:install-file -Dfile=/data3/pinpoint/pinpoint-master/lib/mariaDB4j-2.1.3.jar -DgroupId=ch.vorburger.mariaDB4j -DartifactId=mariaDB4j -Dversion=2.1.3 -Dpackaging=jar -DcreateChecksum=true

mvn install:install-file -Dfile=/data3/pinpoint/pinpoint-master/lib/hbase-client-1.0.0-cdh5.4.0.jar -DgroupId=org.apache.hbase -DartifactId=hbase-client -Dversion=1.0.0-cdh5.4.0 -Dpackaging=jar -DcreateChecksum=true

mvn install:install-file -Dfile=/data3/pinpoint/pinpoint-master/lib/hbase-0.90.3.jar -DgroupId=org.apache.hbase -DartifactId=hbase -Dversion=0.90.3 -Dpackaging=jar -DcreateChecksum=true

/data3/pinpoint/pinpoint-1.5.1/commons-hbase/pom.xml新增

<dependency>
    <groupId>org.apache.hadoop</groupId>
    <artifactId>hadoop-core</artifactId>
    <version>1.2.1</version>
</dependency>

HBase 可以自己安装,也可以直接使用工程的脚本 (建议使用脚本):

Download & Start - Run quickstart/bin/start-hbase.sh

Initialize Tables - Run quickstart/bin/init-hbase.sh

部署 Collector 端:
将 pinpoint-collector-1.5.1.war 部署到你的 web 容器下,我的配置:/data3/tomcat8-Collector port:18080

部署 Web UI 端:
将 pinpoint-web-1.5.1.war 部署到你的 web 容器下,我的配置:/data3/tomcat8-Web port:28080

打开前端: http://10.210.228.50:28080

这里写图片描述

这时还没有被测试应用,本文以 tomcat 容器为例, 在 bin/catalina.sh 中添加:

#pinpoint agent路径
CATALINA_OPTS="$CATALINA_OPTS -javaagent:/data1/hugang/pinpoint/pinpoint-agent-1.5.1/pinpoint-bootstrap-1.5.1.jar"
#被监控工程使用agent的标识号
CATALINA_OPTS="$CATALINA_OPTS -Dpinpoint.agentId=0000002"
#被监控工程名字
CATALINA_OPTS="$CATALINA_OPTS -Dpinpoint.applicationName=10.75.0.101_8086_自定义"

并且需修改 pinpoint-agent 的配置文件/data1/hugang/pinpoint/pinpoint-agent-1.5.1/pinpoint.config,指定 pinpoint Collector 的 ip

profiler.collector.ip=10.210.228.50

启动被测试服务,访问该服务。

4.查看数据

这时查看 Pinpoint web UI,左上下拉框选择你的应用:

4.1 trace 链路分析

圈中你想查看这次访问的链路信息,圈中右上访问时间散列图中的某个点(一个点代表一次访问)

这里写图片描述

这里写图片描述

4.2 性能数据

这里写图片描述

这里写图片描述

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
共收到 4 条回复 时间 点赞

移动端的 apm 监控产品有开源的吗

#1 楼 @seveniruby 安卓版本下可以用手淘的 Dexposed:https://github.com/alibaba/dexposed, 它可以 Hook 系统类里的方法并且是运行时的,可以二次开发,进行性能监控。可以参考视频:http://www.infoq.com/cn/presentations/mobile-phone-taobao-hotpatch-technology-introduction?utm_campaign=rightbar_v2&utm_source=infoq&utm_medium=presentations_link&utm_content=link_text

#1 楼 @seveniruby 我所了解的,客户端没有类似 APM 的工具;我的理解是客户端是单维度的,是运行在单台手机上的应用,数据来源都是调服务端的接口,而手机端性能监控大都是监控你本台手机的指标(cpu, 内存, 流量, 耗电, 帧率等),可以用 Dexposed Hook 不同的系统方法 进行性能数据统计; 而服务端是分布式,缓存层级(MC, REDIS),持久层(MYSQL)等,APM 主要是面向服务端的应用。

已经开始对 Tomcat 应用监控。其他类型的还没时间研究如何配置。

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