jconsole观察分析Java程序的运行,进行排错调优

假如想象 提交于 2019-12-06 16:07:33

jsconsole非授权远程连接

-Djava.rmi.server.hostname=172.16.10.218 -Dcom.sun.management.jmxremote.port=8999 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false

linux运行定时任务程序 报错如下:

Exception thrown by the agent : java.net.MalformedURLException: Local host name unknown: java.net.UnknownHostException: =mail.06taobao.com

解决:hostname =wangfw-smarttrip-dev-8.novalocal 没有对应一个ip地址,在/etc/hosts中添加127.0.0.1 =wangfw-smarttrip-dev-8.novalocal

授权连接可以看看这篇文章:

http://www.linuxidc.com/Linux/2015-02/113420.htm

性能分析

下面说说如何分析,如何使用这六个标签

概述: Displays overview information about the Java VM and monitored values.

内存: 显示内存使用信息

线程: 显示线程使用信息

类: 显示类装载信息

*VM摘要:*显示java VM信息

MBeans: 显示 MBeans.

以上这些介绍大家可以看下这篇博客详细介绍

http://jiajun.iteye.com/blog/810150

这里主要讲解下根据jsconsole线程提供的堆栈信息检查判断性能瓶颈

背景如下:

这里两天做下单的性能测试发现,在优化Thrfit接口参数以及调优了jvm参数之后,最好的tps就是在80左右,无法再往上提升了;

Thrift 默认socket连接轮休线程数,以及逻辑处理线程数,所以有时候还是需要改下对应的默认参数的,我们项目组优化了这两个参数之后,tps直接翻倍

 /** The number of threads for selecting on already-accepted connections */
    public int selectorThreads = 2;
    /**
     * The size of the executor service (if none is specified) that will handle
     * invocations. This may be set to 0, in which case invocations will be
     * handled directly on the selector threads (as is in TNonblockingServer)
     */
    private int workerThreads = 5;

以下为线程堆栈信息,下面对应指向了交易的代码;review此处代码发现,这个地方存在数据库锁,所以不管优化哪里,此处都会存在竞争关系,所以必须等待,这也就是为什么tps上不去的原因;

输入图片说明

// 商品已售数量增加减操作;
		int effectRow = goodModuleDao.updateGoodsBuyRuleHadSaleNumForPackage(packageGoods.getGoodsPackageBuyRule()
				.getId(), voucher.getMaxUseNumber());
		if (effectRow != 1) {
			logger.error("商品库存不足 voucherData" + voucherData);
			throw new BussinessExceptionNeedCatch(OrderModuleErrorCode.GOODS_STOCK_FINISH_ERROR);
		}

针对扣减库存的方式,此处由于与业务逻辑绑定在一起的,所以从整个架构来说是暂时没法修改的;必须从整体规划来解决此问题,已提供更高的吞吐量;

分享下一些服务化处理方法: 输入图片说明

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!