5

When deploying our application (Java, Spring) on Tomcat 7 it is fine. Now that we upgraded to Tomcat 8 it is very slow when serving static content. Looking at developer tools (see snapshot below), each request of static content (small .js and .css files) it takes as much as we have configured for connectionTimeout in server.xml. Because default is 20000, it may take 20 secs. for each file. When dropping this to 1000 it will be faster, and take 1 sec. for each one.

This happens in different development machines using default configurations. Other processes (web services requests, etc.) are performing ok.

I wonder what and where to start looking.

Developer tools snapshot

krause
  • 436
  • 5
  • 24
  • 1
    What is the specific tomcat 8 version, how do you serve the static content? Was your tomcat 7 install a default one? –  Oct 19 '15 at 17:34
  • Tomcat 7 was a default one. It had worked fine for one year across different sub-versions of 7.x and different machines. Tomcat 8 that I am currently using is 8.0.23, but I suspect other developers may be using slightly different versions. – krause Oct 19 '15 at 17:40
  • I added a snapshot to illustrate the sequence. – krause Oct 20 '15 at 17:06
  • @krause Could you please highlight the evidence for the problem in the screen shot uploaded. I am unable to identify any anamoly. – shanmuga Oct 20 '15 at 17:22
  • @shanmug : Well, I think the idea is that once that the first .htm file was loaded (which actually is a .jsp), then the browser tries to download (or the server to serve) some static content. It takes very close to 20 seconds to load very small .css and .js files. And then 20 seconds again to download some pictures of a couple of kb. – krause Oct 20 '15 at 17:54
  • Taking the risk to repeat myself: how do you serve the static content? Without this information I don't see how someone could help –  Oct 20 '15 at 18:29
  • @RC. Thanks for your message and sorry for not writing this before. As I read your comment, I doubled checked and tried to understand how the content was being delivered. I thought there was not anything special in it. I was lost trying to wonder whether there was anything wrong with spring-security configuration. Then I realized about that CompressionFilter being used that I was not aware of.I'd say that somehow your questions helped me that way, so thanks so much for that. – krause Oct 22 '15 at 14:02
  • Glad the issue is fixed :) –  Oct 22 '15 at 14:37

3 Answers3

5

This is indeed caused by an issue in the Ziplet compression filter due to a servlet spec 3.1 change (setContentLengthLong function).

I've created a pull request to fix it.

This pull request is merged into main and released on April 18th 2016 (ziplet-2.1.0)

R. Oosterholt
  • 7,720
  • 2
  • 53
  • 77
3

The plugin described below (pjl-comp-filter) was used as a CompressionFilter, which turned out not to be compatible with Tomcat 8 as per an open issue in Github for ziplet (its successor) : https://github.com/ziplet/ziplet/issues/6

I replaced it with one of these solutions and it worked :

Which compression (is GZIP the most popular) servlet filter would you suggest?

So former configuration, non working with Tomcat 8 was :

Dependency in pom.xml :

    <dependency>
        <groupId>org.sourceforge</groupId>
        <artifactId>pjl-comp-filter</artifactId>
    </dependency>

And web.xml :

<filter>
    <filter-name>CompressingFilter</filter-name>
    <filter-class>com.planetj.servlet.filter.compression.CompressingFilter</filter-class>
    <init-param>
        <param-name>includeContentTypes</param-name>
        <param-value>text/html,multipart/form-data,text/css,application/x-javascript</param-value>
    </init-param>
    <init-param>
        <param-name>compressionThreshold</param-name>
        <param-value>256</param-value>
    </init-param>
</filter>

<filter-mapping>
    <filter-name>CompressingFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
Community
  • 1
  • 1
krause
  • 436
  • 5
  • 24
0

In my case I just remove the compress filter from web.xml and everything back to normal.

The xml below don't work with tomcat 8, at least no in my application.

<filter>
    <filter-name>compressionFilter</filter-name>
    <filter-class>com.googlecode.webutilities.filters.CompressionFilter</filter-class>
    <init-param> 
        <param-name>compressionThreshold</param-name>
        <param-value>1024</param-value>
    </init-param>
    <init-param> 
        <param-name>ignoreURLPattern</param-name>
        <param-value>.*\.(flv|mp3|mpg)</param-value>
    </init-param>
    <init-param> 
        <param-name>ignoreMimes</param-name>
        <param-value>images/*,video/*, multipart/x-gzip</param-value>
    </init-param>
    <init-param> 
        <param-name>ignoreUserAgentsPattern</param-name>
        <param-value>.*MSIE.*</param-value>
    </init-param>
 </filter>
 <filter-mapping>
    <filter-name>compressionFilter</filter-name>
    <url-pattern>*</url-pattern>
 </filter-mapping> 
Marco Blos
  • 933
  • 9
  • 22