Topic: Improving send_file Performance

Topic type:

Kete's private files function by default uses a Mongrel instance (or Apache mod_rails fork) to stream files to the browser. In some cases this can be very inefficient, so a couple of special headers can be sent instead by setting a Kete configuration option.


When Kete sends a private file to a browser, it normally uses a Mongrel cluster instance or Apache mod_rails fork to stream the file to the browser. This ties up a server instance for at least the length of the request, and in some cases with Mongrel, the Mongrel instance and retain memory used to the buffer the file indefinitely (i.e. causing memory leak).

In order to improve Kete performance in situations like these, Kete supports using Nginx's X-Accel-Redirect and Apache2 (+mod_xsendfile)'s X-SENDFILE to send files directly to the browser without tying up server instances.


Basic instructions for configuring Kete to send files using either of these methods are as follows:

  1. Configure Nginx or Apache2 to accept the relevant header. In the case of Apache2, mod_xsendfile will need to be installed and configured.
  2. Set the correct value for the SENDFILE_METHOD constant in config/initializers/send_file_options.rb.

Complete instructions can be found in config/initializers/send_file_options.rb.

See for a online version of this in the Kete source code.

Discuss This Topic

There are 0 comments in this discussion.

join this discussion