arthas 是阿里巴巴开源的强大的jvm 应该分析工具,以下是使用arthas 生成jvm 火焰图的一个学习
项目使用docker-compose 运行,对于生成的火焰图使用nginx 提供一个访问入口

环境准备

  • docker-compose 文件
 
version: "3"
services: 
  web:
    image: openresty/openresty:alpine
    ports:
    - "8090:80"
    volumes: 
    - "./flamegraph:/opt/mywebs"
    - "./nginx.conf:/usr/local/openresty/nginx/conf/nginx.conf"
  app:
    build: ./
    cap_add: 
    - ALL
    ports:
    - "8080:8080"
    volumes: 
    - "./flamegraph:/usr/local/tomcat/arthas-output"
  • tomcat 集成arthas dockerfile
FROM tomcat
# copy arthas
COPY --from=hengyunabc/arthas:latest /opt/arthas /opt/arthas
  • nginx config
worker_processes 1;
user root;  
events {
    worker_connections 1024;
}
http {
    include mime.types;
    default_type application/octet-stream;
    sendfile on;
    lua_code_cache off;
    lua_need_request_body on;
    gzip on;
    resolver 127.0.0.11 ipv6=off;          
    real_ip_header X-Forwarded-For;
    real_ip_recursive on;
    gzip_min_length 2k;
    gzip_buffers 4 16k;
    log_format compression '$remote_addr - $remote_user [$time_local] '
                       '"$request" $status $bytes_sent '
                       '"$http_referer" "$http_user_agent" "$gzip_ratio"';
    gzip_comp_level 4;
    gzip_types text/plain text/css image/png application/javascript image/jpeg image/gif;
    server {
        listen 80;
        server_name _;
        charset utf-8;
        default_type text/html;
        root /opt/mywebs;
        location / {
           default_type text/plain;
           autoindex on;
        }
        location = /empty {
            empty_gif;
        }
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
            root html;
        }
    }
}

使用

  • 启动
docker-compose up -d
  • 进入tomcat 启动arthas
docker-compose exec app sh 
java -jar /opt/arthas/arthas-boot.jar
选择进程id 默认为1
  • 开启profiler
    生成火焰图
 
profiler start
  • 一个简单的压力测试
ab -n 20000 -c 200 http://localhost:8080/
  • 停止profiler
profiler stop
  • 查看火焰图

说明

以上是一个简单的学习使用,开启容器的profiler 需要添加cap 为了简单,添加了all,arthas 功能很强大,是一把利器,同时集成到docker
镜像中,可以方便的分析一些性能瓶颈

参考资料

https://alibaba.github.io/arthas/
https://github.com/rongfengliang/arthas-docker-demo
https://github.com/alibaba/arthas

使用arthas 生成火焰图分析jvm的更多相关文章

  1. 火焰图分析openresty性能瓶颈

    注:本文操作基于CentOS 系统 准备工作 用wget从https://sourceware.org/systemtap/ftp/releases/下载最新版的systemtap.tar.gz压缩包 ...

  2. 用 CPI 火焰图分析 Linux 性能问题

    https://yq.aliyun.com/articles/465499 用 CPI 火焰图分析 Linux 性能问题   yangoliver 2018-02-11 16:05:53 浏览1076 ...

  3. 火焰图分析CPU性能问题

    1.找出应用程序或内核消耗CPU的PID 2.执行perf record 命令,记录该PID的行为 perf record -a -g -p 14851 -- sleep 30 --30秒后退出 3. ...

  4. perf + Flame Graph火焰图分析程序性能

    1.perf命令简要介绍 性能调优时,我们通常需要分析查找到程序百分比高的热点代码片段,这便需要使用 perf record 记录单个函数级别的统计信息,并使用 perf report 来显示统计结果 ...

  5. [转]perf + 火焰图分析程序性能

    1.perf命令简要介绍 性能调优时,我们通常需要分析查找到程序百分比高的热点代码片段,这便需要使用 perf record 记录单个函数级别的统计信息,并使用 perf report 来显示统计结果 ...

  6. perf + 火焰图分析程序性能

    1.perf命令简要介绍 性能调优时,我们通常需要分析查找到程序百分比高的热点代码片段,这便需要使用 perf record 记录单个函数级别的统计信息,并使用 perf report 来显示统计结果 ...

  7. Skynet服务热点火焰图分析

    最近花了一周时间对场景服务进行热点分析,利用以前的火焰图工具做了一点微小的贡献,分享下心得(仓库地址在https://github.com/spin6lock/skynet_systemtap_set ...

  8. 利用火焰图分析ceph pg分布

    前言 性能优化大神Brendan Gregg发明了火焰图来定位性能问题,通过图表就可以发现问题出在哪里,通过svg矢量图来查看性能卡在哪个点,哪个操作占用的资源最多 在查看了原始数据后,这个分析的原理 ...

  9. 使用FlameGraph火焰图分析JAVA应用性能

    开源项目推荐 Pepper Metrics是我与同事开发的一个开源工具(https://github.com/zrbcool/pepper-metrics),其通过收集jedis/mybatis/ht ...

随机推荐

  1. 一、SqlServer查询今天的数据-多写法对比性能问题

    -- 目标:查询当天的所有数据 -- 说明:表数据行数:960w --方法一:使用格式化被查询条件与格式化当前时间比对 ),)),) --方法二:使用函数DATEDIFF 比对 --方法三:使用传统比 ...

  2. 记录下github 与 gitee 同时使用

    参考 Gitee(码云).Github同时配置ssh key 中间有一步,创建config文件,然后测试就过不去了. 报错:Bad owner or permissions on C:\\Users\ ...

  3. 解决 Github 图片加载慢的问题

    一.前言 本文主要介绍一种解决 Github 图片加载慢的方法,亲测有效. 笔者博客是使用 Github 作为图床,每次打开博客时的图片加载很慢或者根本加载不出来.这是因为 GitHub 的 CDN ...

  4. docker 更新内存限制步骤

    停止容器: docker stop id 更新配额: docker update -m 80G id 内存参数和大小 容器ID重启容器:docker start id

  5. LeetCode 203:移除链表元素 Remove LinkedList Elements

    删除链表中等于给定值 val 的所有节点. Remove all elements from a linked list of integers that have value val. 示例: 输入 ...

  6. POJ-2661Factstone Benchmark

    Factstone Benchmark Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5577   Accepted: 25 ...

  7. springboot学习源码

    springbootTest 学习源码链接 启动前,需要创建数据库表,修改自己的链接配置 create database test01; use test01; CREATE TABLE catego ...

  8. [CrackMe]160个CrackMe之002

    吾爱破解专题汇总:[反汇编练习]160个CrackME索引目录1~160建议收藏备用 一.逆向分析之暴力破解 暴力破解,对于这种具有提示框的,很好定位. 定位好之后,爆破其跳转语句,就能达到破解目的. ...

  9. 部署Azure环境Web应用程序不能直接访问JSON文件解决方案

    问题: 部署在Azure环境Web应用程序的JSON文件,直接通过浏览器或Web应用访问出现 404 的错误信息. 以下通过Firfox浏览器直接访问JSON文件返回的提示错误信息: “HTML 文档 ...

  10. python之三方库(冷门+热门)

    AES加密库 pycryptodome