<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>AgilePHP &#187; performance</title>
	<atom:link href="http://www.agilephp.net/tag/performance/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.agilephp.net</link>
	<description>开发可以敏捷，人生需要慢慢体味</description>
	<lastBuildDate>Fri, 09 Jul 2010 14:37:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>使用JDK进行Performance Tuning</title>
		<link>http://www.agilephp.net/2010/04/performance-tuning-with-jdk-tools/</link>
		<comments>http://www.agilephp.net/2010/04/performance-tuning-with-jdk-tools/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 13:40:41 +0000</pubDate>
		<dc:creator>bbiao</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[技术]]></category>
		<category><![CDATA[软件]]></category>
		<category><![CDATA[jconsole]]></category>
		<category><![CDATA[jdk]]></category>
		<category><![CDATA[jmap]]></category>
		<category><![CDATA[jps]]></category>
		<category><![CDATA[jvisualvm]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[tuning]]></category>

		<guid isPermaLink="false">http://www.agilephp.net/2010/04/%e4%bd%bf%e7%94%a8jdk%e8%bf%9b%e8%a1%8cperformance-tuning/</guid>
		<description><![CDATA[JDK里有三个很好用的工具，jmap，jconsole和jvisualvm，三个工具都各有所侧重，但是如果你的系统遇到性能瓶颈（内存不足或是CPU占用率过高），你可以通过这三个工具来发现应用里的hot spot。我今天只记一下大概的用法，给自己做个备忘，详细的使用说明，等忙完了这段时间，整理一下。
先介绍一个小工具，jps，这也是jdk自带的工具之一，可以列出系统里所有的java进程。
jmap可以查看程序中堆的使用情况，具体的用法是：
jmap –histo:live &#60;pid&#62;；
以及可以将堆dump到一个文件，命令是：
jmap –dump:format=b,file=heap.bin &#60;pid&#62;；
请在&#60;pid&#62;处填入相应的进程的id。
jconsole可以查看某个java进程的内存使用、CPU占用率等，
如果想要远程查看某一java程序，则需要在该程序启动参数里加下如下参数：
-Dcom.sun.management.jmxremote   -Dcom.sun.management.jmxremote.port=9001     -Dcom.sun.management.jmxremote.authenticate=false    -Dcom.sun.management.jmxremote.ssl=false
上文使用的9001是监听的端口号，你可以指定其他的值。然后在你的终端键入jconsole，选择连接远程进程，并填入相应的主机名和端口即可。如果无法连接，请修改/etc/hosts里的内容，将localhost绑定到机器的外部ip地址。
相应的数据可以导出为一个csv文件，这个很方便。
jvisualvm功能与jconsole的基本类似，但是可以做性能分析。
即可以分析出CPU时间被哪些线程所占用了，等等，并且它支持jmx，这东西我只听说过没用过，先放一边不表。
配置jvisualvm不需要改动原程序的启动参数，只需要在远程主机上运行jstatd即可。
新建一个叫jstatd.all.policy的文件，内容是：
grant codebase &#34;file:${java.home}/../lib/tools.jar&#34; {   &#160;&#160;&#160; permission java.security.AllPermission;    };
然后使用如下命令启动jstatd，
jstatd -J-Djava.security.policy=jstatd.all.policy
然后在jvisualvm里选择添加远程主机即可。如果无法连接，请修改/etc/hosts里的内容，将localhost绑定到机器的外部ip地址。










Related Posts

		Java中线程同步的简单用法
		Python and RRD
		QQ五笔输入法
	
<!-- Easy AdSense V2.90 -->
<!-- Post[count: 3] -->
<div class="ezAdsense adsense adsense-leadout" style="float:left;margin:12px;"><script type="text/javascript"><!--
google_ad_client = "pub-1450467177950189";
/* AgilePHP Lite Ad */
google_ad_slot = "7710335250";
google_ad_width = 234;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<!-- Easy AdSense V2.90 -->



<h3>Related Posts</h3>
<ol>
		<li><a href="http://www.agilephp.net/2009/10/java-wait-and-notify/" rel="bookmark">Java中线程同步的简单用法</a><!-- (5.53993)--></li>
		<li><a href="http://www.agilephp.net/2010/01/python-and-rrd/" rel="bookmark">Python and RRD</a><!-- (4.87102)--></li>
		<li><a href="http://www.agilephp.net/2009/12/qq-wubi-input-method/" rel="bookmark">QQ五笔输入法</a><!-- (4.83449)--></li>
	</ol>
]]></description>
			<content:encoded><![CDATA[<p>JDK里有三个很好用的工具，<a href="http://java.sun.com/j2se/1.5.0/docs/tooldocs/share/jmap.html">jmap</a>，<a href="http://java.sun.com/developer/technicalArticles/J2SE/jconsole.html">jconsole</a>和<a href="http://java.sun.com/javase/6/docs/technotes/tools/share/jvisualvm.html">jvisualvm</a>，三个工具都各有所侧重，但是如果你的系统遇到性能瓶颈（内存不足或是CPU占用率过高），你可以通过这三个工具来发现应用里的hot spot。我今天只记一下大概的用法，给自己做个备忘，详细的使用说明，等忙完了这段时间，整理一下。</p>
<p>先介绍一个小工具，jps，这也是jdk自带的工具之一，可以列出系统里所有的java进程。</p>
<p><strong>jmap可以查看程序中堆的使用情况，具体的用法是：</strong></p>
<p>jmap –histo:live &lt;pid&gt;；</p>
<p>以及可以将堆dump到一个文件，命令是：</p>
<p>jmap –dump:format=b,file=heap.bin &lt;pid&gt;；</p>
<p>请在&lt;pid&gt;处填入相应的进程的id。</p>
<p><strong>jconsole可以查看某个java进程的内存使用、CPU占用率等，</strong></p>
<p>如果想要远程查看某一java程序，则需要在该程序启动参数里加下如下参数：</p>
<p>-Dcom.sun.management.jmxremote   <br />-Dcom.sun.management.jmxremote.port=<em>9001     <br /></em>-Dcom.sun.management.jmxremote.authenticate=false    <br />-Dcom.sun.management.jmxremote.ssl=false</p>
<p>上文使用的9001是监听的端口号，你可以指定其他的值。然后在你的终端键入jconsole，选择连接远程进程，并填入相应的主机名和端口即可。<em>如果无法连接，请修改/etc/hosts里的内容，将localhost绑定到机器的外部ip地址。</em></p>
<p>相应的数据可以导出为一个csv文件，这个很方便。</p>
<p><strong>jvisualvm功能与jconsole的基本类似，但是可以做性能分析。</strong></p>
<p>即可以分析出CPU时间被哪些线程所占用了，等等，并且它支持<a href="http://java.sun.com/javase/technologies/core/mntr-mgmt/javamanagement/">jmx</a>，这东西我只听说过没用过，先放一边不表。</p>
<p>配置jvisualvm不需要改动原程序的启动参数，只需要在远程主机上运行<a href="http://java.sun.com/j2se/1.5.0/docs/tooldocs/share/jstatd.html">jstatd</a>即可。</p>
<p>新建一个叫jstatd.all.policy的文件，内容是：</p>
<p>grant codebase &quot;file:${java.home}/../lib/tools.jar&quot; {   <br />&#160;&#160;&#160; permission java.security.AllPermission;    <br />};</p>
<p>然后使用如下命令启动jstatd，</p>
<p>jstatd -J-Djava.security.policy=jstatd.all.policy</p>
<p>然后在jvisualvm里选择添加远程主机即可。<em>如果无法连接，请修改/etc/hosts里的内容，将localhost绑定到机器的外部ip地址。</em></p>


<h3>Related Posts</h3>
<ol>
		<li><a href="http://www.agilephp.net/2009/10/java-wait-and-notify/" rel="bookmark">Java中线程同步的简单用法</a><!-- (5.53993)--></li>
		<li><a href="http://www.agilephp.net/2010/01/python-and-rrd/" rel="bookmark">Python and RRD</a><!-- (4.87102)--></li>
		<li><a href="http://www.agilephp.net/2009/12/qq-wubi-input-method/" rel="bookmark">QQ五笔输入法</a><!-- (4.83449)--></li>
	</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.agilephp.net/2010/04/performance-tuning-with-jdk-tools/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>大数据量系统</title>
		<link>http://www.agilephp.net/2010/02/system-scalability-and-performance/</link>
		<comments>http://www.agilephp.net/2010/02/system-scalability-and-performance/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 02:54:58 +0000</pubDate>
		<dc:creator>bbiao</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[技术]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[scalability]]></category>
		<category><![CDATA[大数据量]]></category>

		<guid isPermaLink="false">http://www.agilephp.net/2010/02/%e5%a4%a7%e6%95%b0%e6%8d%ae%e9%87%8f%e7%a8%8b%e5%ba%8f/</guid>
		<description><![CDATA[这半个月一直在忙，忙着改程序，做实验，原来的系统的处理能力是10^4/10^5，我现在需要处理的数据量是10^6/10^7。原来正常的程序却出现了各种各样的异常，最明显的问题有两个，一个是OutOfMemory，一个是Connection Reset。
前一个问题有很多种不同的解决方法，就是增加机器的物理内存，调优jvm的启动参数，如果这些都解决不了问题，那就是程序本身的问题。我遇到的最多的就是BufferedReader溢出、ArrayList的不正确使用。这些问题都解决了还是会发现莫明其妙的溢出的话，还是增加物理内存吧。jvm虽然有垃圾收集机制，但是如果程序设计的初衷就没有为大数据量的数据考虑过的话，内存消耗真是件杯具而且及其不好解决在问题，特别是在code base有10^5级别的时候。
后一个问题，目前我还没有找到好的解决办法，目前能想到的，就是增加发送和接收缓存，平滑发送的速率，可是16*16的链接还是会莫明其妙的断掉。
郁闷了！还是需要再接再厉，外围的方案解决不了问题的话，只能去动核心的代码了。身边也没有有经验的人可以请教，我自己现在倒是对大数据量、巨数据量系统的可伸缩性和性能有了很强的兴趣。


Related Posts

		使用JDK进行Performance Tuning
	


<h3>Related Posts</h3>
<ol>
		<li><a href="http://www.agilephp.net/2010/04/performance-tuning-with-jdk-tools/" rel="bookmark">使用JDK进行Performance Tuning</a><!-- (3)--></li>
	</ol>
]]></description>
			<content:encoded><![CDATA[<p>这半个月一直在忙，忙着改程序，做实验，原来的系统的处理能力是10^4/10^5，我现在需要处理的数据量是10^6/10^7。原来正常的程序却出现了各种各样的异常，最明显的问题有两个，一个是OutOfMemory，一个是Connection Reset。</p>
<p>前一个问题有很多种不同的解决方法，就是增加机器的物理内存，调优jvm的启动参数，如果这些都解决不了问题，那就是程序本身的问题。我遇到的最多的就是BufferedReader溢出、ArrayList的不正确使用。这些问题都解决了还是会发现莫明其妙的溢出的话，还是增加物理内存吧。jvm虽然有垃圾收集机制，但是如果程序设计的初衷就没有为大数据量的数据考虑过的话，内存消耗真是件杯具而且及其不好解决在问题，特别是在code base有10^5级别的时候。</p>
<p>后一个问题，目前我还没有找到好的解决办法，目前能想到的，就是增加发送和接收缓存，平滑发送的速率，可是16*16的链接还是会莫明其妙的断掉。</p>
<p>郁闷了！还是需要再接再厉，外围的方案解决不了问题的话，只能去动核心的代码了。身边也没有有经验的人可以请教，我自己现在倒是对大数据量、巨数据量系统的可伸缩性和性能有了很强的兴趣。</p>


<h3>Related Posts</h3>
<ol>
		<li><a href="http://www.agilephp.net/2010/04/performance-tuning-with-jdk-tools/" rel="bookmark">使用JDK进行Performance Tuning</a><!-- (3)--></li>
	</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.agilephp.net/2010/02/system-scalability-and-performance/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
