Bug 56513 - Javadoc change for NIO compression and NIO sendfile
Summary: Javadoc change for NIO compression and NIO sendfile
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 8
Classification: Unclassified
Component: Documentation (show other bugs)
Version: 8.0.x-trunk
Hardware: PC All
: P2 normal (vote)
Target Milestone: ----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-12 12:11 UTC by Martin Gainty
Modified: 2014-05-12 16:12 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Gainty 2014-05-12 12:11:51 UTC
In NIO Connector documentation
compression is mentioned
sendfile use is mentioned
but the 2 clearly do not work together in a NIO Connector

https://tomcat.apache.org/tomcat-7.0-doc/aio.html states

    When APR or NIO is enabled, Tomcat supports using sendfile to send large static files. These writes, as soon as the system load increases, will be performed asynchronously in the most efficient way. Instead of sending a large response using blocking writes, it is possible to write content to a static file, and write it using a sendfile code. A caching valve could take advantage of this to cache the response data in a file rather than store it in memory. Sendfile support is available if the request attribute org.apache.tomcat.sendfile.support is set to Boolean.TRUE.

    Any servlet can instruct Tomcat to perform a sendfile call by setting the appropriate request attributes. It is also necessary to correctly set the content length for the response. When using sendfile, it is best to ensure that neither the request or response have been wrapped, since as the response body will be sent later by the connector itself, it cannot be filtered. Other than setting the 3 needed request attributes, the servlet should not send any response data, but it may use any method which will result in modifying the response header (like setting cookies).

  org.apache.tomcat.sendfile.filename: Canonical filename of the file which will be sent as a String
  org.apache.tomcat.sendfile.start: Start offset as a Long
  org.apache.tomcat.sendfile.end: End offset as a Long

Needs to state:

NIO works with either sendfile OR compression
NIO with Sendfile:

NIO with Compression:

http://tomcat.apache.org/tomcat-7.0-doc/config/http.html#NIO_specific_configuration states

(with regards to compression)
Note: There is a tradeoff between using compression (saving your bandwidth) and using the sendfile feature (saving your CPU cycles). If the connector supports the sendfile feature, e.g. the NIO connector, using sendfile will take precedence over compression. The symptoms will be that static files greater that 48 Kb will be sent uncompressed. You can turn off sendfile by setting useSendfile attribute of the connector, as documented below, or change the sendfile usage threshold in the configuration of the DefaultServlet in the default conf/web.xml or in the web.xml of your web application. 

Needs to say:

NIO works with sendfile feature OR compression
NIO with Sendfile:

NIO with Compression:
Comment 1 Christopher Schultz 2014-05-12 14:25:36 UTC
(In reply to Martin Gainty from comment #0)
> Needs to state:
> 
> NIO works with either sendfile OR compression
> NIO with Sendfile:
> 
> NIO with Compression:
> 
> http://tomcat.apache.org/tomcat-7.0-doc/config/http.
> html#NIO_specific_configuration states

Also for the APR connector.

> (with regards to compression)
> Note: There is a tradeoff between using compression (saving your bandwidth)
> and using the sendfile feature (saving your CPU cycles). If the connector
> supports the sendfile feature, e.g. the NIO connector, using sendfile will
> take precedence over compression. The symptoms will be that static files
> greater that 48 Kb will be sent uncompressed. You can turn off sendfile by
> setting useSendfile attribute of the connector, as documented below, or
> change the sendfile usage threshold in the configuration of the
> DefaultServlet in the default conf/web.xml or in the web.xml of your web
> application. 
> 
> Needs to say:
> 
> NIO works with sendfile feature OR compression
> NIO with Sendfile:
> 
> NIO with Compression:

Seems reasonable.

Care to submit a documentation patch?
Comment 2 Mark Thomas 2014-05-12 16:12:39 UTC
Fixed for 8.0.6 onwards.