- 浏览: 173528 次
- 性别:
- 来自: 青岛
文章分类
最新评论
-
hugang357:
...
java String to byte[] -
lyzhu:
winstr
使用JAVASCRIPT实现弹出框,过一段时间自动消失 -
laoliu.org:
要是稍微整理一下成一个健全类就更好了,呵呵。
我把它转到IT民 ...
java月份时间(第一天,最后一天) -
kaituozhe6666:
...
使用JAVASCRIPT实现弹出框,过一段时间自动消失 -
damocreazy:
试一试
如何让EditPlus可以编译执行Java程序
使用resin已经有四、五年了,但以前都是做一些小系统,resin的压力并不大,近段时间做一个大系统,日平均ip上10万,resin的压力非常的大,除了对程序做优化以外,resin 的优化也小不了。
一、优化配置
修改 conf/resin.conf 文章中的 JVM参数
<jvm-arg>-Xms512m</jvm-arg>
<jvm-arg>-Xss128k</jvm-arg>
<jvm-arg>-Xmn184m</jvm-arg>
<jvm-arg>-XX:ParallelGCThreads=20</jvm-arg>
<jvm-arg>-XX:+UseConcMarkSweepGC</jvm-arg>
<jvm-arg>-XX:+UseParNewGC</jvm-arg>
<jvm-arg>-Xdebug</jvm-arg>
<jvm-arg>-Xloggc:gc.log</jvm-arg>
修改 最大thread-max为2500
<!-- Maximum number of threads. -->
<thread-max>2500</thread-max>
<!-- Configures the socket timeout -->
<socket-timeout>65s</socket-timeout>
<!-- Configures the keepalive -->
<keepalive-max>10240</keepalive-max>
<keepalive-timeout>30s</keepalive-timeout>
二、利用resin-admin监控resin运行情况。
第一行是Thread pool情况,如果发现Peak大于thread max,就应该修改conf/resin.conf 中的thread-max,相应的增大thread-max。
第二行是Threads,如果长期出现在这里而又不是SUN的方法,或者resin的方法的话,就要对这些方法进行测试、优化。
最近发现有人用黑客类工具恶意点击网站,或发送大量垃圾包,具体是什么不清楚,但是很明显是故意的,造成80端口无法正常访问,或访问速度极慢。
用netstat -an >>c:\temp\aaa.txt 命令查看了当时情况,发现某几个ip的连接数量巨大,是不正常的。
不管是访问量大,还是有黑客骚扰,我想还是试试看把resin优化一下。
首先要在访问量巨大的时候进行观察。
先将resin.conf文件中的thread-min,thread-max,thread-keepalive三个参数设置的比较大,分别写上,1000,3000,1000,当然这是根据你的机器情况和可能同时访问的数量决定的,如果你的网站访问量很大的,应该再适当放大。
然后观察任务管理器中的java线程变化情况,看看到底是线程达到多大的时候,java进程当掉的。我的是在379左右当掉。
然后将thread-min,thread-max,thread-keepalive分别写为150,400,300;,也就是将当掉的时候的最大值稍微放大点,作为thread-max的值,因为该系统一般不会超过这个值。然后其他两个参数根据情况设置一下。
这只是我的估计值,根据机器性能和访问量不同,应该有所不同。
然后将accept-buffer-size值设置的较大,我设置到10000以上,这样可以让java能使用到更多的内存资源。
这样的设置基本上能够满足resin的正常运行,当掉resin服务的情况大大减少,本设置适合于中小型网站。
Resin Threads |
Resin will automatically allocate and free threads as the load requires. Since the threads are pooled, Resin can reuse old threads without the performance penalty of creating and destroying the threads. When the load drops, Resin will slowly decrease the number of threads in the pool until is matches the load.
Most users can set thread-max to something large (200 or greater) and then forget about the threading. Some ISPs dedicate a JVM per user and have many JVMs on the same machine. In that case, it may make sense to reduce the thread-max to throttle the requests.
Since each servlet request gets its own thread, thread-max determines the maximum number of concurrent users. So if you have a peak of 100 users with slow modems downloading a large file, you'll need a thread-max of at least 100. The number of concurrent users is unrelated to the number of active sessions. Unless the user is actively downloading, he doesn't need a thread (except for "keepalives").
Keepalives |
Keepalives make HTTP and srun requests more efficient. Connecting to a TCP server is relatively expensive. The client and server need to send several packets back and forth to establish the connection before the first data can go through. HTTP/1.1 introduced a protocol to keep the connection open for more requests. The srun protocol between Resin and the web server plugin also uses keepalives. By keeping the connection open for following requests, Resin can improve performance.
<resin ...> <thread-pool> <thread-max>250</thread-max> </thread-pool> <server> <keepalive-max>500</keepalive-max> <keepalive-timeout>120s</keepalive-timeout> ... |
Timeouts
Requests and keepalive connections can only be idle for a limited time before Resin closes them. Each connection has a read timeout, request-timeout. If the client doesn't send a request within the timeout, Resin will close the TCP socket. The timeout prevents idle clients from hogging Resin resources.
... <thread-pool> <thread-max>250</thread-max> </thread-pool> <server> <http port="8080" read-timeout="30s" write-timeout="30s"/> ... |
... <thread-max>250</thread-max> <server> <cluster> <client-live-time>20s</client-live-time> <srun id="a" port="6802" read-timeout="30s"/> </cluster> ... |
In general, the read-timeout and keepalives are less important for Resin standalone configurations than Apache/IIS/srun configurations. Very heavy traffic sites may want to reduce the timeout for Resin standalone.
Since read-timeout will close srun connections, its setting needs to take into consideration the client-live-time setting for mod_caucho or isapi_srun. client-live-time is the time the plugin will keep a connection open. read-timeout must always be larger than client-live-time, otherwise the plugin will try to reuse a closed socket.
Plugin keepalives (mod_caucho/isapi_srun)
The web server plugin, mod_caucho, needs configuration for its keepalive handling because requests are handled differently in the web server. Until the web server sends a request to Resin, it can't tell if Resin has closed the other end of the socket. If the JVM has restarted or if closed the socket because of read-timeout, mod_caucho will not know about the closed socket. So mod_caucho needs to know how long to consider a connection reusable before closing it. client-live-time tells the plugin how long it should consider a socket usable.
Because the plugin isn't signalled when Resin closes the socket, the socket will remain half-closed until the next web server request. A netstat will show that as a bunch of sockets in the FIN_WAIT_2 state. With Apache, there doesn't appear to be a good way around this. If these become a problem, you can increase read-timeout and client-live-time so the JVM won't close the keepalive connections as fast.
unix> netstat ... localhost.32823 localhost.6802 32768 0 32768 0 CLOSE_WAIT localhost.6802 localhost.32823 32768 0 32768 0 FIN_WAIT_2 localhost.32824 localhost.6802 32768 0 32768 0 CLOSE_WAIT localhost.6802 localhost.32824 32768 0 32768 0 FIN_WAIT_2 ... |
TCP limits (TIME_WAIT)
A client and a server that open a large number of TCP connections can run into operating system/TCP limits. If mod_caucho isn't configured properly, it can use too many connections to Resin. When the limit is reached, mod_caucho will report "can't connect" errors until a timeout is reached. Load testing or benchmarking can run into the same limits, causing apparent connection failures even though the Resin process is running fine.
The TCP limit is the TIME_WAIT timeout. When the TCP socket closes, the side starting the close puts the socket into the TIME_WAIT state. A netstat will short the sockets in the TIME_WAIT state. The following shows an example of the TIME_WAIT sockets generated while benchmarking. Each client connection has a unique ephemeral port and the server always uses its public port:
unix> netstat ... tcp 0 0 localhost:25033 localhost:8080 TIME_WAIT tcp 0 0 localhost:25032 localhost:8080 TIME_WAIT tcp 0 0 localhost:25031 localhost:8080 TIME_WAIT tcp 0 0 localhost:25030 localhost:8080 TIME_WAIT tcp 0 0 localhost:25029 localhost:8080 TIME_WAIT tcp 0 0 localhost:25028 localhost:8080 TIME_WAIT ... |
The socket will remain in the TIME_WAIT state for a system-dependent time, generally 120 seconds, but usually configurable. Since there are less than 32k ephemeral socket available to the client, the client will eventually run out and start seeing connection failures. On some operating systems, including RedHat Linux, the default limit is only 4k sockets. The full 32k sockets with a 120 second timeout limits the number of connections to about 250 connections per second.
If mod_caucho or isapi_srun are misconfigured, they can use too many connections and run into the TIME_WAIT limits. Using keepalives effectively avoids this problem. Since keepalive connections are reused, they won't go into the TIME_WAIT state until they're finally closed. A site can maximize the keepalives by setting thread-keepalive large and setting live-time and request-timeout to large values. thread-keepalive limits the maximum number of keepalive connections. live-time and request-timeout will configure how long the connection will be reused.
... <thread-pool> <thread-max>250</thread-max> </thread-pool> <server> <keepalive-max>250</keepalive-max> <keepalive-timeout>120s</keepalive-timeout> <cluster> <client-live-time>120s</client-live-time> <srun id="a" port="6802" read-timeout="120s"/> </cluster> ... |
read-timeout must always be larger than client-live-time. In addition, keepalive-max should be larger than the maximum number of Apache processes.
Apache 1.3 issues
Using Apache as a web server on Unix introduces a number of issues because Apache uses a process model instead of a threading model. The Apache processes don't share the keepalive srun connections. Each process has its own connection to Resin. In contrast, IIS uses a threaded model so it can share Resin connections between the threads. The Apache process model means Apache needs more connections to Resin than a threaded model would.
In other words, the keepalive and TIME_WAIT issues mentioned above are particularly important for Apache web servers. It's a good idea to use netstat to check that a loaded Apache web server isn't running out of keepalive connections and running into TIME_WAIT problems.
先将resin.conf文件中的thread-min,thread-max,thread-keepalive三个参数设置的比较大,分别写上,1000,3000,1000,当然这是根据你的机器情况和可能同时访问的数量决定的,如果你的网站访问量很大的,应该再适当放大。
然后观察任务管理器中的java线程变化情况,看看到底是线程达到多大的时候,java进程当掉的。我的是在379左右当掉。
然后将thread-min,thread-max,thread-keepalive分别写为150,400,300;,也就是将当掉的时候的最大值稍微放大点,作为thread-max的值,因为该系统一般不会超过这个值。然后其他两个参数根据情况设置一下。
这只是我的估计值,根据机器性能和访问量不同,应该有所不同。
然后将accept-buffer-size值设置的较大,我设置到10000以上,这样可以让java能使用到更多的内存资源。
这样的设置基本上能够满足resin的正常运行,当掉resin服务的情况大大减少,本设置适合于中小型网站。
Resin优化:
The allocation of memory for the JVM is specified using -X options when starting Resin
(the exact options may depend upon the JVM that you are using, the examples here are for the Sun JVM).
JVM option passed to Resin Meaning
-Xms initial java heap size
-Xmx maximum java heap size
-Xmn the size of the heap for the young generation
Resin startup with heap memory options unix> bin/httpd.sh -Xmn100M -Xms500M -Xmx500M win> bin/httpd.exe -Xmn100M -Xms500M -Xmx500M install win service> bin/httpd.exe -Xmn100M -Xms500M -Xmx500M -install
原文:http://www.caucho.com/resin-3.0/performance/jvm-tuning.xtp
JVM 优化:
java -Xms<size>
set initial Java heap size. default:Xms32m
java -Xmx<size>
set maximum Java heap size. default:Xmx128m
set it like that:
java -Xms=32m -Xmx=256m
If the problem persist, increase Xmx more than 256 ( 512m for example )
-J-mx<num>
Resin启动时通过bin目录下的wrapper.pl文件进行控制,我们可以修改这个文件来加一些参数,比如要加入Java的-Xms和-Xmx参数
进行
vi /usr/local/resin-2.1/bin/wrapper.pl
找到并修改以下这行为:
$JAVA_ARGS="-Xms512m -Xmx512m";
具体参数请根据自己的应用进行调节
log设置 name 是指定对各个层次应用进行debug,name 设定有几种情况,如: level 的级别一般有:: path: 输出文件路径指向,可以形式如 path=’stdout:’ 注意后面有冒号;或指定绝对路径path=’/usr/local/resin-3.0.7/log/stdout.log’ 一般设置日志文件一周轮循一次,即 rollover-period=’1M’ 或 rollover-period=’7D’ , 当满一周,系统会自动生成新日志记录文件,格式如: stderr.log.20041201 stderr.log.20041208 |
当不需要改动程序时,关闭java自动编译会更快些.
<compiling-loader path="webapps/WEB-INF/classes" />
加个属性
batch="false"
$JAVA_ARGS="-server";
据说java中的-server参数是让本地化编译更完全.
转http://www.blogjava.net/jelver/articles/183376.html
发表评论
-
resin 3.1 配置
2011-04-02 13:59 771<!-- Resin 3.1 配置文件. --> ... -
[转帖]Subversion权限详解
2011-03-14 14:13 6531 背景假设 厦门央瞬公司是一家电子元器件设 ... -
CollabNetSubversionEdge-1.3.1安装与配置 使用
2011-02-17 11:16 33191、双击CollabNetSubversionEdge-1 ... -
SubVersion和Subclipse的简单使用方法
2011-02-17 11:01 1010版本 CollabNetSubversion-server-1 ... -
同一台服务器上一个resin配置多个应用,启动独立
2011-02-11 10:31 1578原文地址:http://jadewoo.iteye.com/b ... -
Resin3.1下resin.conf配置文件说明
2011-02-11 10:24 824原贴地址:http://dolphin-ygj.iteye.c ... -
Windows下打造Apache+JSP+CGI+PHP+ASP+MySQL完美服务器平台
2008-08-27 13:27 3239地址http://1cpu.cn/read-htm-tid-6 ... -
resin配置心得
2008-02-13 11:52 3201引自:http://itfeng.blog.techweb.c ... -
网友杂谈各种APP SERVER(昨天讨论的总结)
2008-02-13 10:24 1183比较杂,比较乱,大家看的时候只能“随意”一些了。呵呵。还是按应 ... -
Tomcat启动分析
2008-01-26 11:13 1233Tomcat启动分析heavyz, 2003- ... -
tomcat增加jvm使用的内存的方法
2008-01-12 10:50 1896tomcat增加jvm使用的内存的方法 发表人:wo ... -
教你使用solr搭建你的全文检索
2008-01-12 09:40 1820教你使用solr搭建你的全文检索引用:http://bbs.z ...
相关推荐
总结来说,Resin的Eclipse插件是Java开发者在使用Eclipse开发基于Resin 3.1的应用时的重要辅助工具,它提供了一整套集成了Resin服务器管理、应用部署、日志查看等功能,极大地优化了开发流程。通过阅读提供的博文...
### Resin 3.1 配置文件解析与说明 ...理解和掌握这些配置项对于优化 Resin 的性能、满足特定的应用需求至关重要。希望本文能帮助开发者更好地利用 Resin 的强大功能,构建高效稳定的企业级应用系统。
Resin 3.1配置文件详解 Resin是一款高性能、轻量级的Java应用服务器,...通过熟练配置Resin,你可以更好地优化应用部署,解决可能出现的问题,提高开发和运维效率。不断学习和实践,你将成为Resin服务器的真正主人。
1. **高性能的Servlet容器**:Resin3优化了Servlet的处理机制,确保了高并发场景下的高效运行。 2. **JSP支持**:对JSP的出色支持使得开发者能够快速构建动态Web页面,提升了开发效率。 3. **内存管理**:Resin3采用...
Resin 3.1中文配置手册是一份详细指导文档,旨在帮助用户理解和配置Resin服务器。Resin是一款高性能、轻量级的Java应用服务器,它支持Servlet、JSP、EJB以及Quercus(PHP的Java实现)等多种技术。这份手册涵盖了从...
Resin 3.1.3版本是该软件的一个特定迭代,可能包含了对之前版本的优化和修复。 1. **Resin服务器的核心特性:** - **快速响应**:Resin以其高性能而著称,它采用高效的线程模型和内存管理,能够处理高并发请求。 ...
这篇博客文章“resin中关于日志的配置”着重讲解了如何在Resin服务器上管理和配置日志系统,这对于监控应用状态、调试问题以及优化性能至关重要。下面将详细阐述相关知识点。 1. **日志的重要性**: - 日志记录了...
9. **日志和监控**:Resin提供了详细的日志记录和服务器状态监控功能,帮助开发者定位问题和优化性能。 10. **配置管理**:通过XML配置文件,用户可以灵活配置Resin的各项设置,如服务器端口、线程池大小、缓存策略...
5. **性能监控**:实时监控Resin服务器的资源使用情况,如CPU、内存和网络,帮助优化应用性能。 6. **配置管理**:直接在Eclipse中编辑和管理Resin服务器的配置文件,如`resin.xml`,减少手动修改配置文件的繁琐...
Resin Pro 3.1.9 是一款高效且功能丰富的Java应用服务器,它由Caucho Technology公司开发,主要用于托管Web应用程序。Resin以其高性能、轻量级和稳定性著称,是许多企业和开发者的选择。在深入探讨Resin Pro 3.1.9的...
Resin 4.0.58是该软件的一个特定版本,它在发布时可能包含了性能优化、安全更新和其他改进。以下是对Resin 4.0.58以及与Java、Windows 64位系统相关的知识点的详细解释: 1. **Resin服务器**:Resin设计为一个快速...
### Resin 服务器配置指南详解 #### 一、Resin 服务器简介与应用场景 Resin 是一款高性能且...通过以上配置指南和实践操作,我们可以有效地对 Resin 服务器进行优化和管理,提高其在实际生产环境中的稳定性和性能。
8. **内存管理和优化**:Resin通过智能内存管理策略减少了内存泄漏的可能性,并且可以根据应用的需求自动调整内存分配。 9. **配置灵活性**:Resin的配置可以通过XML文件进行,提供了丰富的选项来定制服务器的行为...
- 运行`Resin3.1`目录下的`setup.exe`,选择IIS/PWS选项。 - 将`isapi_srun.dll`复制到`C:\Inetpub\scripts`目录。 - 创建`resin.ini`文件,内容包括: ``` ResinConfigServer localhost 6802 IISPriority ...
Resin是由Caucho Technology开发的一款开源Java应用服务器,它支持Servlet 3.1、JSP 2.3以及Java EE 6规范。Resin以其快速的响应速度和高效的内存管理而著名,特别适合处理高并发的Java Web应用。Resin 4.0版本带来...
这意味着开发人员可以利用诸如Servlet 3.0、JSP 2.2、EJB 3.1等特性来构建现代的、可扩展的应用程序。这些标准的集成使得Resin成为开发企业级应用的理想选择,因为它提供了丰富的API和工具,便于开发、测试和部署。 ...
- **线程配置**:讨论了 Resin 如何管理和优化线程池,以提高并发处理能力和响应速度。 ##### 1.2 环境配置 (Environment): 类加载器、资源和 JNDI (Class Loaders, Resources and JNDI) 这一节深入探讨了 Resin ...
### Eclipse配合Resin开发Web应用及MySQL数据库连接池配置整合与...通过以上步骤,不仅可以在Eclipse中顺利搭建起基于Resin的Web开发环境,还可以有效地管理和优化数据库连接池,从而提高Web应用的整体性能和稳定性。
此外,Resin 4.0.65还增强了对Java EE 6规范的支持,包括CDI(Contexts and Dependency Injection)、EJB 3.1和JSF 2.0等,使得开发者可以更加方便地构建企业级应用。 在安全性方面,Resin 4.0.65加强了SSL/TLS的...