Michal Singer wrote:
The useSendfile relates to connectors, the configuration I understand is needed is in under Engine > Host 
> Context (<Context            docBase="../../work/bundles"            
path="/bundles")

Can you explain how the " useSendfile" relates to static files?
Is the configuration I am using correct? Or is there another way to configure 
the use of static files?

Hi.  Let me explain, in not too technical or precise terms, what the 
useSendFile means.

Normally, to copy a filesystem file to the servlet response filehandle, you 
would
a) open the file, using some read buffer size
b) start a loop reading a chunk of the file, and writing that chunk to the response filehandle, and then loop and do it again until you reach the EOF on the input file.
c) close the input file
And you would do all that using Java I/O code, so that it is portable across 
OS'es.

Modern OS'es have a "sendfile" function, built in the OS itself. Basically, it is a very optimised piece of code, by which an application (like a Java JVM) can tell the OS : here is the path to a file on the filesystem, and here is a "filehandle" to which this file should be copied. The OS sendfile function then arranges everything to do this as efficiently as possible under that particular OS and filesystem, and for Java it is one function call instead of a Java I/O loop.

By setting the "useSendFile" attribute to true, you basically allow Tomcat to use the builtin sendfile of the OS to send the servlet response (instead of a Java I/O loop like the above). It only works if the input is a static file on the filesystem, but for such files it is probably at least 50% more efficient than the corresponding Java loop. It is bound to the Connector, because the Connector is the object which "holds" the filehandle to the client TCP socket, where the response must ultimately be sent.

Another thing : the sendfile option will probable only work with the "APR native" connector. So check your Tomcat startup messages to verify that this is what you are using.

And yet another thing : all this will make it more efficient for the server CPU and disks, to send back a static file. But it has no impact on the available bandwidth of your server-to-client link, or on the client itself.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to