微服务性能分析|Pyroscope 在 Rainbond 上的实践分享


本文将介绍一个 「持续性能分析平台 Pyroscope」,它能够帮助我们快速找到内存泄漏、CPU利用率高的代码。

什么是 Pyroscope?

Pyroscope 是一个开源的持续性能分析平台。它能够帮你:

  • 查找代码中的性能问题
  • 解决 CPU 利用率高的问题
  • 定位并修复内存泄漏
  • 了解应用程序的调用树
  • 跟踪随时间的变化

Pyroscope 可以存储来自多个应用程序长期的分析数据;可以一次查看多年的数据或单独查看特定的事件;较低的 CPU 使用;数据压缩效率高,磁盘空间要求低;快捷的 UI 界面;

Pyroscope 架构

Pyroscope 由两个主要组件支撑运行:「Pyroscope Server」「Pyroscope Agent」

「Pyroscope Agent」:记录并汇总您的应用程序一直在执行的操作,然后将该数据发送到 Pyroscope Server。支持多种语言,GO、Python、Ruby、eBPF、JAVA、Rust、PHP、NodeJS、.NET

「Pyroscope Server」: 处理、聚合和存储来自代理的数据,以便在任何时间范围内快速查询。片刻后可以查看分析数据,并在任何时间范围内进行查询。

与 Rainbond 集成架构

「1.集成 Pyroscope Agent:」

使用 Rainbond 插件的机制在微服务组件内安装 Pyroscope Agent 插件,该插件会将 pyroscope.jar 通过 javaagent 方式启动 java -javaagent:pyroscope.jar -jar app.jar

「2.依赖 Pyroscope Server:」

将安装了 Pyroscope Agent 插件微服务组件都依赖至 Pyroscope Server。


本文将基于微服务框架 Pig 进行实践,步骤为:

  1. 部署微服务 Spring Cloud Pig,Gitee:https://gitee.com/log4j/pig
  2. 部署 Pyroscope Server
  3. 安装 Pyroscope Java Agent 插件并配置
  4. 建立微服务与 Pyroscope 之间的依赖关系
  5. Pyroscope 基本使用

Rainbond 部署请参阅文档 快速安装

1. 部署微服务 Spring Cloud Pig

通过开源应用商店一键安装 Spring Cloud Pig,新增 -> 基于应用商店创建组件 -> 在开源应用商店中搜索 SpringCloud-Pig 并安装到指定应用中。

2. 部署 Pyroscope Server

通过开源应用商店一键安装Pyroscope Server,新增 -> 基于应用商店创建组件 -> 在开源应用商店中搜索 Pyroscope 并安装到指定应用中。

3. 安装 Pyroscope Java Agent 插件并配置

  1. 插件 -> 从应用商店安装插件,搜索 Pyroscope-Java-Agent 进行安装。
  1. 为每个微服务组件都开通插件,进入微服务组件 -> 插件 -> 开通插件 Pyroscope-Java-Agent 并更新组件。
  1. 为每个微服务组件都设置以下环境变量,可在组件内 -> 环境变量 -> 添加变量。也可以通过应用配置组为所有组件统一配置 JAVA_OPTS 环境变量,而 PYROSCOPE_APPLICATION_NAME 环境变量是唯一的,不可统一配置。
变量名 变量值 说明
JAVA_OPTS -javaagent:/agent/pyroscope.jar Java agent 启动参数

4. 建立微服务与Pyroscope之间的依赖关系

将所有微服务组件添加依赖连接到 Pyroscope,切换到编排模式进行依赖关系建立,并更新或重启所有微服务组件使依赖关系生效。

5. Pyroscope 基本使用

访问 Pyroscope 的 4040 对外服务端口,即可访问 Pyroscope UI。

在 Single View 视图中,可以通过 Application 选择服务。它可以显示某一段时间内的火焰图,也可以使用表格展示或者同时展示,火焰图可以看到微服务方法调用的性能指标。

在 Comparison View 视图中,可以选择不同的时间段进行比较,通过时间线拖拽即可。

在 Diff View 视图中,可以进行两个时间段的差异比对,这通常在排查微服务的CPU、内存泄漏时很有效。


Pyroscope 还可以结合 Jaeger 一起使用,可以集成在 Jaeger UI 中,可参阅 Jaeger UI 集成

Rainbond 是一个云原生应用管理平台,核心100%开源、使用简单、不需要懂容器和Kubernetes,支持管理多种Kubernetes集群,提供企业级应用的全生命周期管理。


评论 5

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #4

    Hello Guys, I just completed my divorce with my cheating husband of 10 years with two beautiful kids when i got a solid evidence of his unfaithfulness on extra marital affairs and his infidelity lifestyle, And the various applications he used to hide chats and lot of secret on his cell phone. Then, i decided to hire (Henry clark) an hacker and a PI just to be 100% sure because i don’t want to confront him or take any kinda step without proof, fact and figures because that could leads to defamation… It was with this great, honest, professional and trustworthy Man i got to know my husband is a professional cheater and has been using this app to hide most of his chats. This great hacker helped me broke to into his cell phone activities and wired everything he does on his cell phone directly to my phone and i was able to monitor and track him directly from my phone remotely without him knowing,
    Contact the Ethical hacker via email, Henryclarkethicalhacker@gmail.com you can also reach him on Whatsapp 18134211326..

    Steve Jenna4个月前 (09-19)回复
    • Finding your partner cheating isn’t easy. People who cheat are generally smart enough to hide it. Therefore, their partners often spend nights awake wondering if their suspicions are true or not. Luckily today you are going to read about a way through which you can know for sure if your partner is cheating on you. This happens by sending a mail to Jeffreyethicalhacker Don’t worry, you aren’t going to need your partner’s phone in order to see what your partner had been up to. The way I told you worked for me, and it was remotely.
      contact him via email; Jeffreyethicalhacker@gmail.com
      whatsapp or Text on : +1 (747)345-9036

      dda liey5542个月前 (12-04)回复
  2. #3

    Contact him for any type of hacking, he is a professional hacker that specializes in exposing cheating spouses, and every other hacking related issues. he is a cyber guru, he helps catch cheating spouses by hacking their communications like call, Facebook, text, emails, Skype, whats-app and many more. I have used this service before and he did a very good job, he gave me every proof I needed to know that my fiancee was cheating. You can contact him on his email to help you catch your cheating spouse, or for any other hacking related problems, like hacking websites, bank statement, grades and many more. he will definitely help you, he has helped a lot of people, contact him on, Henryclarkethicalhacker@gmail.com, and you can Text/Call &WhatsApp: +1 (262)-236-7526, and figure out your relationship status. I wish you the best.

    Lucy Janet3个月前 (11-13)回复
  3. #2

    Tracking cellphones and getting an accurate report has been a bit worrisome, thanks to Jeffrey whose service helped me locate certain cellphones without breaking a sweat. His service made me know that the internet has become the most common method of cheating nowadays, either emotionally or physically. Taking a few extra steps in getting what would serve as proof for leaving a toxic relationship, to see who your spouse texts or chats with on social media isn’t a bad idea, I’d recommend you reach out to Jeffreyethicalhacker@gmail.com
    Text,call or whatsapp on: +1 (747)345-9036

    dda liey5542个月前 (11-23)回复
  4. #1

    It took 11 months but I was able to get my money back. Earlier this year I got entangled with a military doctor serving in Syria via a hookup site, we chit-chatted for weeks and she introduced me to cryptocurrency that she has earned massively. I was tempted to try it as I was going through some financial challenges after my chaotic divorce. I did invest $393,000.00 AUD dollars which I got from my divorce settlement. That’s when I realized I have been swindled. Months later, I came across a testimonial, I never thought that after all these months I will be able to recover my lost Bitcoin from those scammers but ( Cybergenie@cyberservices.com )WhatsApp (+1) 252-512-0391). made that possible, here I am with a grateful heart to CYBER GENIE INTERCONTINENTAL…

    Russell B3周前 (01-09)回复