文档章节

Tomcat IO续

强子哥哥
 强子哥哥
发布于 2015/08/23 11:41
字数 1637
阅读 197
收藏 0
点赞 0
评论 0
1.4.3.2 StringCache锁优化

在处理过程中,发现有这么一个锁

"catalina-exec-6" daemon prio=10 tid=0xb7629400 nid=0x86a waiting for monitor entry [0x908e1000]

   java.lang.Thread.State: BLOCKED (on object monitor)

       at org.apache.tomcat.util.buf.StringCache.toString(StringCache.java:221)

       - waiting to lock <0x9c8adaf0> (a java.util.HashMap)

       at org.apache.tomcat.util.buf.ByteChunk.toString(ByteChunk.java:528)

       at org.apache.tomcat.util.buf.MessageBytes.toString(MessageBytes.java:196)

       at org.apache.catalina.connector.Request.getRequestURI(Request.java:2227)

       at org.apache.catalina.valves.AccessLogValve$RequestElement.addElement(AccessLogValve.java:1590)

       at org.apache.catalina.valves.AccessLogValve.log(AccessLogValve.java:962)

       at org.apache.catalina.core.AccessLogAdapter.log(AccessLogAdapter.java:51)

       at org.apache.catalina.core.ContainerBase.logAccess(ContainerBase.java:1263)

       at org.apache.catalina.core.ContainerBase.logAccess(ContainerBase.java:1270)

       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:441)

       at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)

       at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)

       at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1879)

       - locked <0x9d178110> (a org.apache.tomcat.util.net.NioChannel)

       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)

       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

       at java.lang.Thread.run(Thread.java:701)

 

"catalina-exec-5" daemon prio=10 tid=0x91818800 nid=0x869 waiting for monitor entry [0x90932000]

   java.lang.Thread.State: BLOCKED (on object monitor)

       at org.apache.tomcat.util.buf.StringCache.toString(StringCache.java:221)

       - waiting to lock <0x9c8adaf0> (a java.util.HashMap)

       at org.apache.tomcat.util.buf.ByteChunk.toString(ByteChunk.java:528)

       at org.apache.tomcat.util.buf.MessageBytes.toString(MessageBytes.java:196)

       at org.apache.catalina.connector.Request.getRequestURI(Request.java:2227)

       at org.apache.catalina.valves.AccessLogValve$RequestElement.addElement(AccessLogValve.java:1590)

       at org.apache.catalina.valves.AccessLogValve.log(AccessLogValve.java:962)

       at org.apache.catalina.core.AccessLogAdapter.log(AccessLogAdapter.java:51)

       at org.apache.catalina.core.ContainerBase.logAccess(ContainerBase.java:1263)

       at org.apache.catalina.core.ContainerBase.logAccess(ContainerBase.java:1270)

       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:441)

       at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)

       at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)

       at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1879)

       - locked <0x9cdabb90> (a org.apache.tomcat.util.net.NioChannel)

       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)

       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

       at java.lang.Thread.run(Thread.java:701)

 

 

 

 

"catalina-exec-2" daemon prio=10 tid=0x099ea000 nid=0x866 runnable [0x9129a000]

   java.lang.Thread.State: RUNNABLE

       at java.lang.String.equals(String.java:1025)

       at org.apache.tomcat.util.buf.StringCache$ByteEntry.equals(StringCache.java:657)

       at java.util.HashMap.get(HashMap.java:322)

       at org.apache.tomcat.util.buf.StringCache.toString(StringCache.java:293)

       - locked <0x9c8adaf0> (a java.util.HashMap)

       at org.apache.tomcat.util.buf.ByteChunk.toString(ByteChunk.java:528)

       at org.apache.tomcat.util.buf.MessageBytes.toString(MessageBytes.java:196)

       at org.apache.catalina.connector.Request.getRequestURI(Request.java:2227)

       at org.apache.catalina.valves.AccessLogValve$RequestElement.addElement(AccessLogValve.java:1590)

       at org.apache.catalina.valves.AccessLogValve.log(AccessLogValve.java:962)

       at org.apache.catalina.core.AccessLogAdapter.log(AccessLogAdapter.java:51)

       at org.apache.catalina.core.ContainerBase.logAccess(ContainerBase.java:1263)

       at org.apache.catalina.core.ContainerBase.logAccess(ContainerBase.java:1270)

       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:441)

       at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)

       at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)

       at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1879)

       - locked <0x9d0e9a10> (a org.apache.tomcat.util.net.NioChannel)

       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)

       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

       at java.lang.Thread.run(Thread.java:701)

 

"catalina-exec-1" daemon prio=10 tid=0x9180fc00 nid=0x865 waiting for monitor entry [0x910ab000]

   java.lang.Thread.State: BLOCKED (on object monitor)

       at org.apache.tomcat.util.buf.StringCache.toString(StringCache.java:221)

       - waiting to lock <0x9c8adaf0> (a java.util.HashMap)

       at org.apache.tomcat.util.buf.ByteChunk.toString(ByteChunk.java:528)

       at org.apache.tomcat.util.buf.MessageBytes.toString(MessageBytes.java:196)

       at org.apache.catalina.connector.Request.getRequestURI(Request.java:2227)

       at org.apache.catalina.valves.AccessLogValve$RequestElement.addElement(AccessLogValve.java:1590)

       at org.apache.catalina.valves.AccessLogValve.log(AccessLogValve.java:962)

       at org.apache.catalina.core.AccessLogAdapter.log(AccessLogAdapter.java:51)

       at org.apache.catalina.core.ContainerBase.logAccess(ContainerBase.java:1263)

       at org.apache.catalina.core.ContainerBase.logAccess(ContainerBase.java:1270)

       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:441)

       at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)

       at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)

       at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1879)

       - locked <0x9ce8d5c0> (a org.apache.tomcat.util.net.NioChannel)

       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)

       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

       at java.lang.Thread.run(Thread.java:701)

 

这里是为了记录access日志

修改方法:

修改org.apache.tomcat.util.buf.ByteChunk

    // -------------------- Conversion and getters --------------------

 

    @Override

    public String toString() {

        if (null == buff) {

            return null;

        } else if (end-start == 0) {

            return "";

        }

        return StringCache.toString(this);

    }

修改为

    // -------------------- Conversion and getters --------------------

 

  @Override

    public String toString() {

        if (null == buff) {

            return null;

        } else if (end-start == 0) {

            return "";

        }

        //return StringCache.toString(this);

        StringCache.accessCount++;

        return this.toStringInternal();

    }

这里忽略了StringCacheaccessCounthitCount两个统计字段。

 

1.4.3.3 servlet

在调试时,发现有个锁

"catalina-exec-159" daemon prio=10 tid=0x91842c00 nid=0xd30 waiting for monitor entry [0x90473000]

   java.lang.Thread.State: BLOCKED (on object monitor)

   at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:353)

   - waiting to lock <0x9d027848> (a org.apache.jasper.servlet.JspServletWrapper)

   at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)

   at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)

   at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)

   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)

   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)

   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)

   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)

   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)

   at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)

   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)

   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)

   at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)

   at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)

   at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1879)

   - locked <0x9db454c0> (a org.apache.tomcat.util.net.NioChannel)

   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)

   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

   at java.lang.Thread.run(Thread.java:701)

查看源码找到位置所在:

            /*

             * (1) Compile

             */

            if (options.getDevelopment() || firstTime ) {

                synchronized (this) {

                    firstTime = false;

 

                    // The following sets reload to true, if necessary

                    ctxt.compile();

                }

            } else {

                if (compileException != null) {

                    // Throw cached compilation exception

                    throw compileException;

                }

            }

说明如果是开发模式或者第一次加载时,都需要执行此同步块。

通过打印日志

 

 

可以看到,基本上除了因为第一次加载外,其它全部是因为处于开发模式而导致重新进入此模块。

那么如何让Tomcat运行在非Develop模式?

org.apache.jasper.EmbeddedServletOptions565行。

 

 

 

看来可以在配置文件中配置。

在对应的servelt的配置项中

        <init-param>

            <param-name>development</param-name>

            <param-value>false</param-value>

        </init-param>

修改后的效果如下:

 

也可以直接修改代码,将development字段的默认值设置为false.

 

1.4.3.4 AccessLog
 

 

AccessLogValve.java1144行。代码为

synchronized (this) {

                if (writer != null) {

                    writer.println(message);

                    if (!buffered) {

                        writer.flush();

                    }

                }

            }

如果不需要access log记录,则可以屏蔽掉这段代码。

这个根据实际的需要决定。

 

1.4.4 日志锁优化

通过查看线程栈jstack,可以看到

 

 

 

"catalina-exec-6" daemon prio=10 tid=0x90705400 nid=0x4ab waiting for monitor entry [0x906ad000]

   java.lang.Thread.State: BLOCKED (on object monitor)

       at java.io.PrintWriter.write(PrintWriter.java:427)

       - waiting to lock <0x9c551ec8> (a java.io.OutputStreamWriter)

       at java.io.PrintWriter.write(PrintWriter.java:446)

       at org.apache.juli.FileHandler.publish(FileHandler.java:208)

       at java.util.logging.Logger.log(Logger.java:573)

       at java.util.logging.Logger.doLog(Logger.java:598)

       at java.util.logging.Logger.logp(Logger.java:714)

       at org.apache.juli.logging.DirectJDKLog.log(DirectJDKLog.java:183)

       at org.apache.juli.logging.DirectJDKLog.error(DirectJDKLog.java:146)

       at org.apache.tomcat.util.net.NioEndpoint$Poller.addEvent(NioEndpoint.java:1043)

       at org.apache.tomcat.util.net.NioEndpoint$Poller.add(NioEndpoint.java:1081)

       at org.apache.tomcat.util.net.NioEndpoint$Poller.add(NioEndpoint.java:1072)

       at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.release(Http11NioProtocol.java:221)

       at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:616)

       at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1876)

       - locked <0x9cdf2ed8> (a org.apache.tomcat.util.net.NioChannel)

       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)

       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

       at java.lang.Thread.run(Thread.java:701)

 

"catalina-exec-5" daemon prio=10 tid=0x9172ec00 nid=0x4aa runnable [0x906fe000]

   java.lang.Thread.State: RUNNABLE

       at java.io.FileOutputStream.writeBytes(Native Method)

       at java.io.FileOutputStream.write(FileOutputStream.java:300)

       at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:220)

       at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:290)

       at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:294)

       at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:140)

       - locked <0x9c551ec8> (a java.io.OutputStreamWriter)

       at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229)

       at java.io.PrintWriter.flush(PrintWriter.java:293)

       - locked <0x9c551ec8> (a java.io.OutputStreamWriter)

       at org.apache.juli.FileHandler.publish(FileHandler.java:210)

       at java.util.logging.Logger.log(Logger.java:573)

       at java.util.logging.Logger.doLog(Logger.java:598)

       at java.util.logging.Logger.logp(Logger.java:714)

       at org.apache.juli.logging.DirectJDKLog.log(DirectJDKLog.java:183)

       at org.apache.juli.logging.DirectJDKLog.error(DirectJDKLog.java:146)

       at org.apache.tomcat.util.net.NioEndpoint$Poller.addEvent(NioEndpoint.java:1043)

       at org.apache.tomcat.util.net.NioEndpoint$Poller.add(NioEndpoint.java:1081)

       at org.apache.tomcat.util.net.NioEndpoint$Poller.add(NioEndpoint.java:1072)

       at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.release(Http11NioProtocol.java:221)

       at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:616)

       at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1876)

       - locked <0x92350190> (a org.apache.tomcat.util.net.NioChannel)

       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)

       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

       at java.lang.Thread.run(Thread.java:701)

 

"catalina-exec-4" daemon prio=10 tid=0x90700800 nid=0x4a9 waiting for monitor entry [0x90883000]

   java.lang.Thread.State: BLOCKED (on object monitor)

       at java.io.PrintWriter.write(PrintWriter.java:427)

       - waiting to lock <0x9c551ec8> (a java.io.OutputStreamWriter)

       at java.io.PrintWriter.write(PrintWriter.java:446)

       at org.apache.juli.FileHandler.publish(FileHandler.java:208)

       at java.util.logging.Logger.log(Logger.java:573)

       at java.util.logging.Logger.doLog(Logger.java:598)

       at java.util.logging.Logger.logp(Logger.java:714)

       at org.apache.juli.logging.DirectJDKLog.log(DirectJDKLog.java:183)

       at org.apache.juli.logging.DirectJDKLog.error(DirectJDKLog.java:146)

       at org.apache.tomcat.util.net.NioEndpoint$Poller.addEvent(NioEndpoint.java:1043)

       at org.apache.tomcat.util.net.NioEndpoint$Poller.add(NioEndpoint.java:1081)

       at org.apache.tomcat.util.net.NioEndpoint$Poller.add(NioEndpoint.java:1072)

       at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.release(Http11NioProtocol.java:221)

       at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:616)

       at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1876)

       - locked <0x9ce324f0> (a org.apache.tomcat.util.net.NioChannel)

       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)

       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

       at java.lang.Thread.run(Thread.java:701)

 

"catalina-exec-3" daemon prio=10 tid=0x91711800 nid=0x4a8 waiting for monitor entry [0x908d4000]

   java.lang.Thread.State: BLOCKED (on object monitor)

       at java.io.PrintWriter.write(PrintWriter.java:427)

       - waiting to lock <0x9c551ec8> (a java.io.OutputStreamWriter)

       at java.io.PrintWriter.write(PrintWriter.java:446)

       at org.apache.juli.FileHandler.publish(FileHandler.java:208)

       at java.util.logging.Logger.log(Logger.java:573)

       at java.util.logging.Logger.doLog(Logger.java:598)

       at java.util.logging.Logger.logp(Logger.java:714)

       at org.apache.juli.logging.DirectJDKLog.log(DirectJDKLog.java:183)

       at org.apache.juli.logging.DirectJDKLog.error(DirectJDKLog.java:146)

       at org.apache.tomcat.util.net.NioEndpoint$Poller.addEvent(NioEndpoint.java:1043)

       at org.apache.tomcat.util.net.NioEndpoint$Poller.add(NioEndpoint.java:1081)

       at org.apache.tomcat.util.net.NioEndpoint$Poller.add(NioEndpoint.java:1072)

       at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.release(Http11NioProtocol.java:221)

       at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:616)

       at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1876)

       - locked <0x9cc577a0> (a org.apache.tomcat.util.net.NioChannel)

       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)

       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

       at java.lang.Thread.run(Thread.java:701)

 

"catalina-exec-2" daemon prio=10 tid=0x911df000 nid=0x4a7 waiting for monitor entry [0x90925000]

   java.lang.Thread.State: BLOCKED (on object monitor)

       at java.io.PrintWriter.write(PrintWriter.java:427)

       - waiting to lock <0x9c551ec8> (a java.io.OutputStreamWriter)

       at java.io.PrintWriter.write(PrintWriter.java:446)

       at org.apache.juli.FileHandler.publish(FileHandler.java:208)

       at java.util.logging.Logger.log(Logger.java:573)

       at java.util.logging.Logger.doLog(Logger.java:598)

       at java.util.logging.Logger.logp(Logger.java:714)

       at org.apache.juli.logging.DirectJDKLog.log(DirectJDKLog.java:183)

       at org.apache.juli.logging.DirectJDKLog.error(DirectJDKLog.java:146)

       at org.apache.tomcat.util.net.NioEndpoint$Poller.addEvent(NioEndpoint.java:1043)

       at org.apache.tomcat.util.net.NioEndpoint$Poller.add(NioEndpoint.java:1081)

       at org.apache.tomcat.util.net.NioEndpoint$Poller.add(NioEndpoint.java:1072)

       at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.release(Http11NioProtocol.java:221)

       at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:616)

       at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1876)

       - locked <0x9ce18148> (a org.apache.tomcat.util.net.NioChannel)

       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)

       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

       at java.lang.Thread.run(Thread.java:701)

 

"catalina-exec-1" daemon prio=10 tid=0x093c7800 nid=0x4a6 waiting for monitor entry [0x90f5c000]

   java.lang.Thread.State: BLOCKED (on object monitor)

       at java.io.PrintWriter.write(PrintWriter.java:427)

       - waiting to lock <0x9c551ec8> (a java.io.OutputStreamWriter)

       at java.io.PrintWriter.write(PrintWriter.java:446)

       at org.apache.juli.FileHandler.publish(FileHandler.java:208)

       at java.util.logging.Logger.log(Logger.java:573)

       at java.util.logging.Logger.doLog(Logger.java:598)

       at java.util.logging.Logger.logp(Logger.java:714)

       at org.apache.juli.logging.DirectJDKLog.log(DirectJDKLog.java:183)

       at org.apache.juli.logging.DirectJDKLog.error(DirectJDKLog.java:146)

       at org.apache.tomcat.util.net.NioEndpoint$Poller.addEvent(NioEndpoint.java:1040)

       at org.apache.tomcat.util.net.NioEndpoint$Poller.add(NioEndpoint.java:1081)

       at org.apache.tomcat.util.net.NioEndpoint$Poller.add(NioEndpoint.java:1072)

       at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.release(Http11NioProtocol.java:221)

       at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:616)

       at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1876)

       - locked <0x9cd925b8> (a org.apache.tomcat.util.net.NioChannel)

       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)

       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

       at java.lang.Thread.run(Thread.java:701)

可见默认的日志logger效率比较低,因为写文件是互斥锁。

查看at org.apache.juli.logging.DirectJDKLog.error(DirectJDKLog.java:146)

此处可以修改源码为更高效的日志组件。

 

1.4.5 启用压缩

    <Connector executor="tomcatThreadPool"

               port="8080" protocol="HTTP/1.1"

               connectionTimeout="20000"

               redirectPort="8443"

                 compression="on"

               compressionMinSize="2048"

/>

可以使得返回给client的数据量减少。

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

参考

1 http://www.tuicool.com/articles/vU7bya3

2 http://itindex.net/detail/50701-tomcat-bio-nio.apr

3 http://www.365mini.com/page/tomcat-connector-mode.htm

4 http://www.oschina.net/question/54100_16195

5 http://blog.itpub.net/29510932/viewspace-1102187/

 

 

© 著作权归作者所有

共有 人打赏支持
强子哥哥

强子哥哥

粉丝 859
博文 926
码字总数 640946
作品 8
南京
架构师
web服务器适合文件上传下载服务吗?

不去说具体的什么大文件、断点续传。我想问的是上传对服务器并发的影响。 假设线程池为200,如果有200个人同时在上传文件(小文件的话线程占满的情况小点,但是如果传的文件大点,就会导致同...

铂金小虫
2014/10/30
537
3
【新功能】ECS已过期实例续费变配功能上线

中国站ECS控制台,现已支持已过期的实例续费时,对实例规格进行变配。 功能特点 已过期实例续费变配与过去的续费降配有三点区别: 续费变配只可以续费同时修改实例规格配置,不可以修改带宽。...

郁苍
04/17
0
0
【新用户专享】腾讯云发车,360元三年1核2G云服务器

最近发现腾讯云有新用户专享活动,360元即可购买云服务器1核2G、1M带宽,加赠50GB对象存储空间。一般情况,阿里云腾讯云的1核1G云主机就算是促销时,价格也在 300元/1年 以上。如果有需求的,...

FuYung
03/07
0
0
《字符串连接你用+还是用StringBuilder》续

前言 前面的一篇文章《字符串连接你用+还是用StringBuilder》,有朋友找我反馈了一些问题,其中一位朋友说JDK10下生成的字节码跟文章中并不一样,这里继续看下是什么情况。 问题描述 如下图,...

超人汪小建
07/16
0
0
java.io.EOFException java.io.ObjectInputStream$PeekInputStream.readFully 错误

java.io.EOFException java.io.ObjectInputStream$PeekInputStream.readFully 错误 Tomcat启动后报:IOException while loading persisted sessions: java.io.EOFException错误 - IOExceptio......

风中帆
2016/08/26
229
0
java_speed/stream

#Stream 上传插件 Stream 是解决不同浏览器上传文件的插件,是Uploadify的Flash版和Html5版的结合! #Stream 简介 Stream 是根据某网的文件上传插件加工而来,支持不同平台(Windows, Linux,...

java_speed
2014/04/09
0
0
t-io框架使用中出现内存泄漏

我在我的服务器中加入了t-io的框架作为tcp 的连接,我用的是springmvc的框架,在使用中发现当tomcat开启后t-io会单独生成一个独立线程,当tomcat被关闭后,这个t-io所在的线程并没有被关闭,...

码码君
2017/08/31
98
2
OpenRTMFP/Cumulus Primer(12)IO管理之IO流(续)

OpenRTMFP/Cumulus Primer(12)IO管理之IO流(续) Author: 柳大·Poechant(钟超) Email: zhongchao.ustc#gmail.com (#->@) Blog: Blog.CSDN.net/Poechant Date: April 24th, 2012 0 导语......

晨曦之光
2012/04/24
91
0
servlet3异步原理与实践

一、什么是Servlet servlet 是基于 Java 的 Web 组件,由容器进行管理,来生成动态内容。像其他基于 Java 的组件技术一样,servlet 也是基于平台无关的 Java 类格式,被编译为平台无关的字节...

新栋BOOK
2017/10/23
0
0
制作docker镜像

基于alpine制作最小的tomcat镜像 #docker pull docker.io/frolvlad/alpine-oraclejdk8 #获取alpine镜像(包含jdk8),可以下载其他镜像 #tar xf apache-tomcat-8.5.24.tar.gz # mv apache-tomc......

小白的希望
01/12
0
0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

Java基础——异常

声明:本栏目所使用的素材都是凯哥学堂VIP学员所写,学员有权匿名,对文章有最终解释权;凯哥学堂旨在促进VIP学员互相学习的基础上公开笔记。 异常处理: 可以挖很多个陷阱,但是不要都是一样...

凯哥学堂
26分钟前
0
0
180723-Quick-Task 动态脚本支持框架之结构设计篇

文章链接:https://liuyueyi.github.io/hexblog/2018/07/23/180723-Quick-Task-动态脚本支持框架之结构设计篇/ Quick-Task 动态脚本支持框架之结构设计篇 相关博文: 180702-QuickTask动态脚本...

小灰灰Blog
30分钟前
0
0
SBT 常用开发技巧

SBT 一直以来都是 Scala 开发者不可言说的痛,最主要的原因就是官方文档维护质量较差,没有经过系统的、循序渐进式的整理,导致初学者入门门槛较高。虽然也有其它构建工具可以选择(例如 Mill...

joymufeng
34分钟前
0
0
HBase in Practice - 性能、监控及问题解决

李钰(社区ID:Yu Li),阿里巴巴计算平台事业部高级技术专家,HBase开源社区PMC&committer。开源技术爱好者,主要关注分布式系统设计、大数据基础平台建设等领域。连续4年基于HBase/HDFS设计和...

中国HBase技术社区
35分钟前
1
0
ES18-JAVA API 批量操作

1.批量查询 Multi Get API public static void multiGet() {// 批量查询MultiGetResponse response = getClient().prepareMultiGet().add("my_person", "my_index", "1")// 查......

贾峰uk
40分钟前
0
0
SpringBoot2.0使用health

1,引入actuator <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency> 2,application.properties ......

暗中观察
47分钟前
0
0
阿里巴巴Java开发规约

###编程规约 命名风格 【强制】代码中的命名均不能以下划线或美元符号开始,也不能以下划线或美元符号结束 【强制】代码中的命名严禁使用拼音与英文混合的方式,更不允许直接使用中文的方式。...

简心
51分钟前
0
0
如何用TypeScript来创建一个简单的Web应用

转载地址 如何用TypeScript来创建一个简单的Web应用 安装TypeScript 获取TypeScript工具的方式: 通过npm(Node.js包管理器) npm install -g typescript 构建你的第一个TypeScript文件 创建...

durban
56分钟前
0
0
分享好友,朋友圈自定义分享链接无效

这个问题是微信6.5.6版本以后,修改了分享规则:分享的连接必须在公众号后台设定的js安全域名内

LM_Mike
今天
0
0
2018年7月23日课程

一、LVS-DR介绍 director分配请求到不同的real server。real server 处理请求后直接回应给用户,这样director负载均衡器仅处理客户机与服务器的一半连接。负载均衡器仅处理一半的连接,避免了...

人在艹木中
今天
0
0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

返回顶部
顶部