Resin 3 pro高并发,响应性与稳定性方案

以下方案我是在Intel xeon(至强) 3.2G 2个双核物理CPU+2G内存(Ecc)上进行:

resin版本为resin-pro-3.0.21,JVM为Jrockit 1.5_06, resin java 启动参数 -Xms256m -Xmx512m

1. 以下为resin.conf配置
<!–

– Resin 3.0 configuration file.

–>

<resin xmlns=“http://caucho.com/ns/resin”
xmlns:resin=“http://caucho.com/ns/resin/core”>

<!–

– Logging configuration for the JDK logging API.

–>

<log name=“” level=“all” path=“stdout:” timestamp=“[%H:%M:%S.%s] “/>



<logger name=“com.caucho.java” level=“config”/>

<logger name=“com.caucho.loader” level=“config”/>



<dependency-check-interval>600s</dependency-check-interval>



<javac compiler=“internal” args=“”/>



<thread-pool>

<thread-max>10240</thread-max>

<spare-thread-min>50</spare-thread-min>

</thread-pool>



<min-free-memory>5M</min-free-memory>



<server>

<class-loader>

<tree-loader path=“${resin.home}/lib”/>

<tree-loader path=“${server.root}/lib”/>

</class-loader>



<keepalive-max>1024</keepalive-max>

<keepalive-timeout>60s</keepalive-timeout>



<resin:if test=“${resin.isProfessional()}”>

<select-manager enable=“true”/>

</resin:if>



<bind-ports-after-start/>



<http server-id=“” host=“*” port=“80”/>



<cluster>

<srun server-id=“” host=“127.0.0.1” port=“6802”/>

</cluster>



<resin:if test=“${resin.isProfessional()}”>

<persistent-store type=“cluster”>

<init path=“session”/>

</persistent-store>

</resin:if>



<ignore-client-disconnect>true</ignore-client-disconnect>



<resin:if test=“${isResinProfessional}”>

<cache path=“cache” memory-size=“20M”/>

</resin:if>



<web-app-default>

<class-loader>

<tree-loader path=“${server.root}/ext-webapp”/>

</class-loader>



<cache-mapping url-pattern=“/” expires=“60s”/>

<cache-mapping url-pattern=“*.gif” expires=“600s”/>

<cache-mapping url-pattern=“*.jpg” expires=“600s”/>



<servlet servlet-name=“directory”
servlet-class=“com.caucho.servlets.DirectoryServlet”>

<init enable=“false”/>

</servlet>



<allow-servlet-el/>



<session-config>

<enable-url-rewriting>false</enable-url-rewriting>

</session-config>



</web-app-default>



<host-default>

<class-loader>

<compiling-loader path=“webapps/WEB-INF/classes”/>

<library-loader path=“webapps/WEB-INF/lib”/>

</class-loader>



<!–access-log path=“logs/access.log”

format=‘%h %l %u %t “%r” %s %b “%{Referer}i” “%{User-Agent}i”‘
rollover-period=“1W”/–>



<web-app-deploy path=“webapps”/>



<ear-deploy path=“deploy”>

<ear-default>

<!– Configure this for the ejb server



– <ejb-server>

– <config-directory>WEB-INF</config-directory>

– <data-source>jdbc/test</data-source>

– </ejb-server>

–>

</ear-default>

</ear-deploy>



<resource-deploy path=“deploy”/>



<web-app-deploy path=“deploy”/>

</host-default>



<resin:import path=“${resin.home}/conf/app-default.xml”/>



<host-deploy path=“hosts”>

<host-default>

<resin:import path=“host.xml” optional=“true”/>

</host-default>

</host-deploy>



<host id=“” root-directory=“.”>

<web-app id=“/” document-directory=“d:\website\chat”>

</web-app>

</host>



</server>

</resin>





2. 在应用的web.xml中加入resin status查看servlet映射

      <servlet-mapping servlet-class=‘com.caucho.servlets.ResinStatusServlet’>

<url-pattern>/resin-status</url-pattern>

<init enable=“read”/>

</servlet-mapping>



3. 启动resin,确认应用正常启动。

4. 写访问测试程序

import java.io.InputStream;

import java.net.URL;


public class TestURL

{
public static void main(String[] args) throws Exception

{
long a = System.currentTimeMillis();

System.out.println(“Starting request url:”);

for(int i = 0; i < 10000; i++){
URL url = new URL(“http://192.168.1.200/main.jsp”);



InputStream is = url.openStream();

is.close();

System.out.println(“Starting request url:”+i);

}
System.out.println(“request url end.take “(System.currentTimeMillis()-a)“ms”);

}


}



5. 在Jbuilder中执行TestURL

在执行过程中,一边刷新http://192.168.1.200/resin-status,查看resin状态,在http://*:80 中的 Active Threads 和 Total,会一直增长,当长到512的时候不再增长,这时再刷新resin-status页面时,会发现打开很慢。原因是服务器已经达到最大连接数,在等待前面连接的释放而不能接受新的连接。

于是下载Resin 3.0.21源码,搜索 512,发现com.caucho.server.port.Port类中有以下代码:
// default timeout


private long _timeout = 65000L;



private int _connectionMax = 512;//就是这行,查找resin所有源码后,发现没有对这个值进行设置

private int _minSpareConnection = 16;



private int _keepaliveMax = -1;



private int _minSpareListen = 5;

private int _maxSpareListen = 10;


将_connectionMax 改为 20480,然后重新编译并替换resin.jar中的Port类。

6. 重新启动Resin,再次运行TestURL进行测试,这次你会发现Threads Active 和 Total 一直变大,且可以超过512一直增大,在测试程序运行过程中刷新页面,页面响应性能还是不错的.

另,测试过程中Resin会打印出 1-3次 强制执行GC的信息,属于正常。

7.待测试完毕,Threads Active 和 Total 马上降为1.Idle为9,总内存为536.87Meg 空闲内存为480.33M

再经多次测试,结果一致,内存回收正常,表明当前 resin 稳定性和响应性可靠。

出自 JAVA开发者(http://www.chinajavaworld.com)

破解resin-pro-3.1

在网上查看了很多关于resin性能的文章,比较公认的说法是resin比tomcat的性能要高很多。


但最近在csdn上看了一篇文章,说resin 3.x的免费版与tomcat性能已经不相上下了。原因有两个:


1、tomcat从5.0后就开始在性能上不断改进,以达到生产环境的要求;


2、resin从3.0开始分为免费版与pro版,更多的性能改进被放到了pro版中了,所以免费版的性能就下降了。


基于这样的一些原因,更由于resin的pro版支持session持久化存储、负载均衡及cache等高端特性,于是对破解resin pro版产生了兴趣。


经过N个夜晚的奋战,终于把这个pro版给破解了。


网上也有人说破解得不好的resin pro版可能会使性能下降,个人感觉不存在这样的问题,只要破解了即可享用pro版的各种特性,性能也有大幅提高。


以下的resin启动的部分输出:


Resin Professional 3.1.4 (built Tue, 04 Dec 2007 11:27:12 PST)
Copyright(c) 1998-2007 Caucho Technology.  All rights reserved.


Starting Resin on Mon, 31 Dec 2007 17:18:52 +0800 (CST)


[17:18:53.640] {main} Proxy Cache disk-size=1024M memory-size=64M
[17:18:53.656] {main} PingThread[] starting, checking []
[17:18:54.109] {main}
[17:18:54.234] {main} Windows XP 5.1 x86
[17:18:54.343] {main} Java 1.5.0_11-b03, 32, mixed mode, GBK, zh, Sun Microsystems Inc.
[17:18:54.468] {main} user.name: dingl
[17:18:54.593] {main} resin.home = C:\resin-pro-3.1.4
[17:18:54.718] {main} resin.root = C:\resin-pro-3.1.4
[17:18:54.828] {main} resin.conf = /D:/workspace/project/resin-3.1.conf
[17:18:54.828] {main}
[17:18:55.734] {main} WebApp[http://localhost:80] Set web app root system property: ‘webapp.root’ = [D:\workspace\project\WebContent\]
[17:18:59.515] {main} WebApp[http://localhost:80] active
[17:19:00.171] {main} WebApp[http://localhost:80/resin-doc] active
[17:19:00.390] {main} WebApp[http://localhost:80/resin-admin] active
[17:19:00.500] {main} Host[] active
[17:19:00.640] {main} Socket JNI library is not available.
[17:19:00.640] {main} Resin will still run but performance will be slower.
[17:19:00.640] {main} To compile the Socket JNI library on Unix, use ./configure; make; make install.
[17:19:00.796] {main} hmux listening to localhost:6800
[17:19:00.921] {main} http listening to *:80
[17:19:01.140] {main} Server[id=,cluster=app-tier] active
[17:19:01.281] {main} Resin started in 9547ms


 可以看到已经没有关于license的提示了,并且增加了Proxy Cache disk-size=1024M memory-size=64M的输出,说明已经使用了cache来提高性能。


 值得一提的是,要想获得更好的性能,请使用linux/unix系统,因为在windows下,默认安装的resin是不能使用JNI库的,需要手工编译。而在linux/unix下,make源码后就已经将JNI库编译好了。这个特性可以从输出中看出来:


[17:19:00.640] {main} Socket JNI library is not available.
[17:19:00.640] {main} Resin will still run but performance will be slower.


linux/unix系统中没有这样的提示。


目前本blog提供resin-pro-3.1.3版的下载,地址为:


resin-pro-3.1.3 for windows 下载


resin-pro-3.1.3 for linux/unix 下载


resin-pro-3.1.4由于目前标记为dev,暂不破解此版本。3.1.5目前正在开发,尚未发布,目前已经可以看到3.1.5的change log了。


使用ping功能使resin更健壮

由于种种原因,resin有时会遇到resin down机的情况,比如:java.lang.OutOfMemoryError。这样的问题如果从代码角度来解决问题,也不是一时半会能解决的,应急解决方案是启用resin-pro的ping功能。
    <resin:if test=”${isResinProfessional}”>
      <ping>
        <url>http://localhost:8080/ping.jsp</url>
        <sleep-time>1m</sleep-time>
        <try-count>5</try-count>
        <socket-timeout>30s</socket-timeout>
      </ping>
    </resin:if>


ping.jsp可随意写一些代码,纯html代码也行,只能服务器能响应返回200。


如果访问resin访问http://localhost:8080/ping.jsp返回不是200 code,然后再重试try-count次,如果依然不响应200,则将自动重启resin服务。


如果在resin tag下配置了:


  <system-property mail.smtp.host=”127.0.0.1″/>
  <system-property mail.smtp.port=”25″/>


还可以让resin自动给你发个邮件通知你它自动重启过了:


    <ping resin:type=”com.caucho.server.admin.PingMailer”>
      <url>http://localhost:8080/ping.jsp</url>
      <mail-to>[email protected]</mail-to>
      <mail-from>[email protected]</mail-from>
      <mail-subject>Resin ping has failed for server ${’${’}server.name}</mail-subject>
    </ping>


这样配置好了,不管resin出现什么故障,只要resin进程不死,就可以放心睡大觉了。


如果还启用了resin的session持久化存储,用户基本感觉不到服务已经重启过了。


如果启用了resin的cluster,那么请修改httpd.sh,将-server参数加上,不然重启resin后是没有cluster的。


resin服务器突然变慢问题解决办法.

  本人负责的一个网站不知道为什么,由周一开始,突然间变得很慢,有时则很快.搞来搞去,搞了差不多一个星期(部份时间开发新功能去了).终于找到原因了.

 

服务器情况:

linux as4

Intel(R) Xeon(R) CPU            5130  @ 2.00GHz

4G内存,

300Gscsi+320GSATA硬盘.

resin 3.0.23+ lighttpd

 

resin启动参数

-server -verbose:gc -Xdebug -Xloggc:gc.log -Djava.awt.headless=true -XX:PermSize=128M -XX:NewRatio=4 -XX:+UseConcMarkSweepGC -XX:MaxPermSize=200m -XX:NewSize=100 -XX:MaxNewSize=128m -Xmn256m -Xms512m -Xmx512m

 

  服务器运行一直很正常,到了周一,网站变慢,CPU占用50%以上,但内存点使用50%,其中大部分是mysql用去了.load average: 10.02, 10.03, 10.00 .

 

  全部程序都测试过.底层代码也查过.JDK换过,RESIN版本换过,mysql配置也换过.问题依然存在.

 

  利用resin-admin查看情况.

 









Total memory: 501.44Meg
Free memory:

350.37Meg


  

  看上去也正常.不过free memory 变化的很快,由100多M,突然变到300多M.一开始还以为是程序释放了内存.就不去管他了.

 

  经过好多晚的调度,发现一个规律.当启动resin时,一切正常.证明跟jdk版本无关.

 

  今天早上更新服务器程序时,发现resin目录有个gc.log文件.打开一看.全部是gc的执行记录.很多.于是使用tail命令一下.

 

        tail -f gc.log

 

  吓了我一跳,平均每秒就会执行一次gc.问题就在这里.是gc把服务器拖慢了.

 

  于是就把resin的启动参数改一下,把内存改大,gc就不会这么容易触发.

 

        -server -verbose:gc -Xdebug -Xloggc:gc.log -Djava.awt.headless=true -XX:PermSize=128M -XX:NewRatio=4 -XX:+UseConcMarkSweepGC -XX:MaxPermSize=200m -XX:NewSize=100 -XX:MaxNewSize=128m -Xmn256m -Xms1024m -Xmx1024m

 

 

  现在好了,CPU占用只有0.1%左右,有时上到30%多,但很快降下来.load average: 0.05, 0.01, 0.00 <—服务器很健康.

 

  利用resin-admin查看情况.









Total memory: 998.44Meg
Free memory: 607.76Meg

      resin平均使用400M左右的内存,一开始只配置了512给她,怪不得老是gc.呵.

lighttpd configure java web server

我的apache 2.061在window 2003 下老是报告错误,虽然也可以使用但感觉很不爽.
错误入下,找了很久也没有办法,包括修复sockt也没用.
报告队列中的错误: 错误应用程序 Apache.exe,版本 2.0.61.200,错误模块 ntdll.dll,版本 5.2.3790.3959,错误地

一直想找一个替代apache的软件,最近看了lighttpd想用lighttpd来替代apache,先下放过资料.
下载地址.
http://ftp.dtech.hu/pub/WLMP-Project/LightTPD-Win32/



. When to use lighttpd


You can use lighttpd to



  • secure access to your application server
  • reduce load on your server by offloading static requests
  • load balance your application servers
  • use lighttpd’s spambot and bad bot blocking capabilities
  • get more request rewriting and redirecting flexibility
  • use the above flexibility to improve your search engine rankings
  • profit.

2. When not to use lighttpd


You might not like lighttpd if you



  • don’t like configuring software
  • use URL rewriting and ;jsessionid (though a patch is available for this problem).

3. lighttpd modules you need


The following lighty modules are needed:



  • mod_access
  • mod_redirect
  • mod_rewrite
  • mod_proxy

Add them to your server.modules section:

server.modules = (
“mod_accesslog”,
“mod_access”,
“mod_redirect”,
“mod_rewrite”,
“mod_proxy”
,
“mod_status”,
“mod_evhost”,
“mod_expire”
)

4. Denying access to JEE directories


The WEB-INF and META-INF directories shouldn’t be accessible through lighttpd. Files from your development environment also shouldn’t be visible.

url.access-deny = ( “WEB-INF”, “.classpath”, “.project”, “META-INF” )

5. Binding your application server to localhost


To prevent duplicate content penalties, your application server shouldn’t be visible from the web. Even if you run it on a high port, someone might eventually find it.


Binding a web site to localhost looks like this in Orion’s <name>-web-site.xml:

<web-site host=”127.0.0.1″ port=”12345″>
<frontend host=”johannburkard.de” port=”80″/>

Consult your documentation if you aren’t using Orion.


6. Redirecting www. to non-www. hosts


Even if you don’t really need to do this, I recommend doing so. Removing duplicate content will improve your rankings.


The following snippet redirects all visitors from www.<domain> to <domain> with a 301 permanent redirect.

$HTTP[“host”] =~ “^www\.(.*)___FCKpd___3quot; {
url.redirect = ( “^/(.*)” => “http://%1/$1” )
}

You should also redirect all additional domains (johannburkard.com, johann-burkard.org) to your main domain.


7. Proxying dynamic requests


We will use mod_proxy to proxy some requests to your Java application server.


Depending on your site’s structure, one of the following approaches will work better.


Simple JSP


If all you have is a bunch of Java Server Pages, the following mod_proxy rule is sufficient:

proxy.server = ( “.jsp” =>
(
( “host” => “127.0.0.1”,
“port” => “12345”
)
)
)

Note that the JSP must be actual files. You cannot use Servlets mapped to these URIs.


Applications


If you use Servlets or more complex applications, you can proxy URIs by prefix:

proxy.server = ( “/blog/” =>
(
( “host” => “127.0.0.1”,
“port” => “12345”
)
)
)

Proxying with exceptions


If most of your site is dynamic and you have a directory for static content (/assets, /static or so), you can proxy all requests except requests for static files:

$HTTP[“url”] !~ “^/static” {
proxy.server = ( “” =>
(
( “host” => “127.0.0.1”,
“port” => “12345”
)
)
)
}

8. Rewriting requests


lighttpd can dynamically rewrite requests. I mostly use this to use default.jsp as dynamic index file instead of index.html. Here’s an example:

url.rewrite-once = ( “^(.*)/___FCKpd___7quot; => “$1/default.jsp”,
“^(.*)/([;?]+.*)___FCKpd___7quot; => “$1/default.jsp$2” )

This is visible at gra0.com and internally rewrites all requests from / to /default.jsp (including jsessionid and query string).


mod_rewrite can also be used to make URLs shorter. For example, to remove the ?page=comments query string, I use the following:

url.rewrite-once = (
“^/blog/(.*)\.html___FCKpd___8quot; => “/blog/$1.html?page=comments”
)

9. Redirecting requests


You can use mod_redirect to redirect the user to a different URL. Contrary to mod_rewrite where the request is rewritten, a 301 permanent redirect will be sent to the browser.


In this example, I’m redirecting requests to an old domain to a new domain:

$HTTP[“host”] == “olddomain.com” {
url.redirect = (
“^/(.*)___FCKpd___9quot; => “http://newdomain.com/$1”
)
}

10. More things to be aware of



  • The only IP address in your application server log files should be 127.0.0.1. If you need the original address, log the X-FORWARDED-FOR header.
  • Don’t analyze both lighttpd and application server logs – lighty’s log files already contain all requests.
  • You might want to set up virtual hosts sooner or later.
  • Use mod_expire to make resources cacheable. Doing so can make your site a lot faster and save you money.

用mysqldumpslow分析mysql的slow query log

mysql有一个功能就是可以log下来运行的比较慢的sql语句,默认是没有这个log的,为了开启这个功能,要修改my.cnf或者在mysql启动的时候加入一些参数。如果在my.cnf里面修改,需增加如下几行

long_query_time = 1
log-slow-queries = /var/youpath/slow.log
log-queries-not-using-indexes

long_query_time 是指执行超过多久的sql会被log下来,这里是1秒。
log-slow-queries 设置把日志写在那里,可以为空,系统会给一个缺省的文件host_name-slow.log,我生成的log就在mysql的data目录
log-queries-not-using-indexes 就是字面意思,log下来没有使用索引的query。

把上述参数打开,运行一段时间,就可以关掉了,省得影响生产环境。

接下来就是分析了,我这里的文件名字叫host-slow.log。
先mysqldumpslow –help以下,俺主要用的是
-s ORDER what to sort by (t, at, l, al, r, ar etc), ‘at’ is default
-t NUM just show the top n queries
-g PATTERN grep: only consider stmts that include this string

-s,是order的顺序,说明写的不够详细,俺用下来,包括看了代码,主要有
c,t,l,r和ac,at,al,ar,分别是按照query次数,时间,lock的时间和返回的记录数来排序,前面加了a的时倒叙
-t,是top n的意思,即为返回前面多少条的数据
-g,后边可以写一个正则匹配模式,大小写不敏感的

mysqldumpslow -s c -t 20 host-slow.log
mysqldumpslow -s r -t 20 host-slow.log

上述命令可以看出访问次数最多的20个sql语句和返回记录集最多的20个sql。
mysqldumpslow -t 10 -s t -g “left join” host-slow.log
这个是按照时间返回前10条里面含有左连接的sql语句。

用了这个工具就可以查询出来那些sql语句是性能的瓶颈,进行优化,比如加索引,该应用的实现方式等。

Configure lighttpd alias (mod_alias)


This lighttpd module provides for mapping different parts of the host filesystem in the document tree. You can use it for mapping various directories. For example cgi-bin directory mapped to /var/lib/cgi-bin.


Configuration


Open your lighttpd configuration file:


vi /etc/lighttpd/lighttpd.conf


Append/add mod_ alias to list of server modules:
server.modules += ( “mod_alias” )


Examples


Add cgi-bin alias for doamin theos.in
alias.url = ( “/cgi-bin/” => “/home/lighttpd/theos.in/cgi-bin/” )


Browse all documents installed at /usr/share/doc/ directory with following alias:
alias.url = ( “/docs/” => “/usr/share/doc/” )
alias.url += ( “/stats/” => “/home/theos.in/http/webalizer/” )


Open a browser and type url http://theos.in/docs/ or http://your-domain.com/docs/


机子无故变慢?——硬盘的DMA模式变成了PIO模式

如果你的机子变得很慢,甚至连播放影片都有卡声音的现象,又差不

出任何病毒,怎么回事?很可能是你的机子的硬盘的DMA模式变成了PI

O模式了。

  硬盘的DMA模式大家应该都知道吧,硬盘的PATA模式有DMA33、DMA

66、DMA100和DMA133,最新的SATA-150都出来了!一般来说现在大多

数人用的还是PATA模式的硬盘,硬盘使用DMA模式相比以前的PIO模式

传输的速度要快2~8倍。DMA模式的起用对系统的性能起到了实质的作

用。以前有很多文章介绍过如何打开DMA模式,我在这里也就不多说了


  但笔者发现一个新的“问题”——Windows2000、XP、2003系统有

时会自行关闭硬盘的DMA模式,自动改用PIO模式运行!这就造成在使

用以上系统中硬盘性能突然下降,其中最明显的现象有:系统起动速

度明显变慢,一般来说正常WindowsXP系统启动时那个由左向右运动的

滑条最多走2~4次系统就能启动,但这一问题发生时可能会走5~8次

或更多!而且在运行系统时进行硬盘操作时明显感觉变慢,在运行一

些大的软件时CPU占用率时常达到100%而产生停顿,玩一些大型3D游戏

时(比如极品飞车6)画面时有明显停顿(很多人这时以为是自己的显

卡问题,当然如果你使用的是三年前的显卡玩这些游戏是有点老了,

但如果你用的是今年才买的GF显卡那就不是它的问题了),出现以上

问题时大家最好看看自己硬盘的DMA模式是不是被Windows系统自行关

闭了。查看自己的系统是否打开DMA模式:

  1. 双击“管理工具”,然后双击“计算机管理”;

  2. 单击“系统工具”,然后单击“设备管理器”;

  3. 展开“IDE ATA/ATAPI 控制器”节点;

  4. 双击您的“主要IDE控制器”;

  5. 点击“高级设置”。

  看到“设备0”,下面的传输模式应设为“DMA(若可用)”,再

下面“当前传输模式”,如果是“Ultra DMAMode*(*为数字,DMA33

为2,DMA66为4,DMA100为5、DMA133为6)”,那么你的系统正常,但

如果以前你自己设的是“UltraDMAMode

6”又没有改动,而现在是“Ultra DMA Mode 4”或“Ultra DMA

Mode2”更或者是“PIO模式”而且改不过来!可能就是系统自行关闭

了DMA模式了。

  分析问题:

  好了,先来说说问题是如何产生的。在Windows 2000/XP/2003中

有这样一个设定: WindowsIDE/ATAPI端口驱动程序 (Atapi.sys) 累

积收到总共6个超时或循环冗余检验(CRC)错误后,驱动程序将把通信

速度(传送模式)从最快的直接内存访问 (DMA) 模式分步骤降为较慢

的DMA模式。如果驱动程序继续收到超时或 CRC 错误,则驱动程序最

终将把传送模式降为最慢的模式(PIO模式)。问题就在这里!一般来

说一个正常的硬盘很少会有超时或循环冗余检验(CRC)错误,但是当我

们使用这些系统里的挂起(也有叫休眠)并恢复计算机后就很容易造

成超时或循环冗余检验(CRC)错误。因为系统设定的超时值为4秒,当

系统向 ATA 磁盘发出读取请求时如果硬盘回应时间超过 4秒的超时值

时才会产生超时或循环冗余检验(CRC)错误,但因为系统在挂起(也有

叫休眠)时硬盘是在停转状态中,恢复计算机时硬盘有个从停止到运

动的过程,这就很容易造成大部分硬盘回应时间超过4秒的超时值。也

就是说当我们使用计算机挂起6次后系统就会把通信速度(传送模式)

从最快的直接内存访问 (DMA)模式分步骤降为较慢的DMA 模式。如果

挂起6次以上则驱动程序最终将把传送模式降为最慢的模式(PIO 模式

)。这就是Windows系统突然变慢的原因。1

  解决问题:

  若要为受影响的设备重新启用典型DMA或更快DMA的传送模式,请

执行以下操作:

  1. 双击“管理工具”,然后双击“计算机管理”;

  2. 单击“系统工具”,然后单击“设备管理器”;

  3. 展开“IDE ATA/ATAPI 控制器”节点;

  4. 双击您要为其恢复典型 DMA 传送模式的控制器;

  5. 单击“驱动程序”选项卡;

  6. 单击“卸载”。

  当此过程完成后,重新启动您的计算机。当Windows重新启动后,

将重新枚举硬盘控制器,同时与该控制器相连的每个设备的传送模式

将重置为默认值。

  但这样只是把硬盘设备的传送模式重置为默认值,当我们再使用

挂起系统时系统又会自行关闭DMA模式!所以我们还要做以下操作:

  1. 单击“开始”,单击“运行”,键入 Regedit,然后单击“确

定”。

  2. 在注册表中找到并单击以下项:

  HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlClass{4D3

6E96A-E325-11CE-BFC1-08002BE10318}001

  和

  HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlClass{4D3

6E96A-E325-11CE-BFC1-08002BE10318}002

  3. 在“编辑”菜单上,指向“新建”,然后单击“DWORD 值”。

  4. 键入 ResetErrorCountersOnSuccess,然后按 Enter 键。

  5. 在“编辑”菜单上,单击“修改”。

  6. 键入 l,然后单击“确定”。

  7. 按照下列步骤操作,然后退出注册表编辑器:

  注意:上面注册表最后的项“{4D36E96A-E325-11CE-BFC1-08002B

E10318}”列出的带有“0001”编号的子项对应于一台仅有一个IDE控

制器的计算机的主要 IDE 通道和次要 IDE 通道。如果您的计算机有

两个 IDE 控制器,则对于每个控制器,主要 IDE通道和次要IDE 通道

的带有编号的子项分别是:“0001、0002、0003、0004、0005、0006

……”。

  为检查是否找到了正确的子项,请检查子项的 DriverDesc 值是

包含字符串值“主要 IDE通道”,还是包含字符串值“次要IDE 通道

”。

  建立以上注册表键值的目的是:

  在Windows中,使系统向 ATA 磁盘发出读取请求时的 4 秒的超时

值更改为10秒。还实现了一种较不严格的变通策略以在发生超时错误

和 CRC 错误时降低传送模式(从较快的 DMA 模式到较慢的DMA模式,

最终降为 PIO 模式)。以前的情况是,在每当累积发生的超时错误或

CRC 错误的总数达到 6次时,IDE/ATAPI端口驱动程序 (Atapi.sys)将

降低传送模式。当我们建立以上注册表键值实现新的策略后,Atapi.s

ys 仅在连续发生 6次超时错误或 CRC错误后才降低传送模式。

  这一新的策略实现后将大大降低系统降低或关闭DMA传送模式的机

会。现在我们可以安心地使用挂起系统和高性能的DMA硬盘模式,再也

不会发生系统性能突然下降的情况了。

盜版的 Windows XP 有福了!微軟發佈 VLK 大量授權序號!

盜版的 Windows XP PRO 作業系統使用者有福了!

微軟公佈了 VLK 大量授權序號。

更改序號後,無需使用網路上的破解驗證,

使用此序號者,皆可正大光明的通過微軟驗證!

以下序號皆為 VLK 大量授權序號:

HCQ9D-TVCWX-X9QRG-J4B2Y-GR2TT
MRX3F-47B9T-2487J-KWKMF-RPWBY
QC986-27D34-6M3TY-JJXP9-TBGMD
CM3HY-26VYW-6JRYC-X66GX-JVY2D
DP7CM-PD6MC-6BKXT-M8JJ6-RPXGJ
F4297-RCWJP-P482C-YY23Y-XH8W3   
HH7VV-6P3G9-82TWK-QKJJ3-MXR96

所有序號皆適用於 Windows XP/SP1/SP2

【使用說明】:

 1.開啟 KeyFinder, 點選 Option 的 Change Windows Key。

 2.輸入以上 VLK 大量授權序號,任選一組(一定要輸入正確,否會失敗)。

 3.完畢後點選 Change 會出現成功訊息,按下 OK 後,在按 Close。


 

      完畢後點選微軟驗證

巧用tmpfs加速你的linux服务器

巧用tmpfs加速你的linux服务器


今天从朋友高春辉那里又学了一招,就是使用tmpfs,我把他消化后用来实现虚拟磁盘来存放squid的缓存文件和php的seesion。速度快不少哦!


默认系统就会加载/dev/shm ,它就是所谓的tmpfs,有人说跟ramdisk(虚拟磁盘),但不一样。象虚拟磁盘一样,tmpfs 可以使用您的 RAM,但它也可以使用您的交换分区来存储。而且传统的虚拟磁盘是个块设备,并需要一个 mkfs 之类的命令才能真正地使用它,tmpfs 是一个文件系统,而不是块设备;您只是安装它,它就可以使用了。


tmpfs有以下优势:
1。动态文件系统的大小,
2。tmpfs 的另一个主要的好处是它闪电般的速度。因为典型的 tmpfs 文件系统会完全驻留在 RAM 中,读写几乎可以是瞬间的。
3。tmpfs 数据在重新启动之后不会保留,因为虚拟内存本质上就是易失的。所以有必要做一些脚本做诸如加载,绑定的操作。


好了讲了一些大道理,大家看的烦了吧,还是讲讲我的应用吧:)


首先在/dev/stm建个tmp文件夹,然后与实际/tmp绑定


mkdir /dev/shm/tmp
chmod 1777 /dev/shm/tmp
mount –bind /dev/shm/tmp /tmp



1。squid的缓存目录设置


vi /etc/squid/squid.conf


修改成
cache_dir ufs /tmp 256 16 256
这里的第一个256表示使用256M内存,我觉得高性能LINUX双效防火墙HOWTO使用ramdisk的方法还不如直接使用tmpfs,至少每次启动不用mkfs,还可以动态改变大小。


然后重启一下服务,ok,现在所有的squid缓存文件都保存倒tmpfs文件系统里了,很快哦。



2。对php性能的优化


对于一个访问量大的以apache+php的网站,可能tmp下的临时文件都会很多,比如seesion或者一些缓存文件,那么你可以把它保存到tmpfs文件。


保存seesion的方法很简单了只要修改php.ini就行了,由于我已经把/dev/stm/tmp与/tmp绑定,所以不改写也行,至于php程序产生的缓存文件那只能改自己的php程序了:)


希望我的这个方法,能对你有所启发。


参考文档:使用虚拟内存(virtual memory,VM)文件系统和绑定安装