For those looking to have Drupal serve private files efficiently, I've posted a simple core patch that adds X-Sendfile support:
http://drupal.org/node/74472

X-Sendfile is a feature provided by modern web servers (including Apache2 and Lighttpd) that provides a significant performance benefit for sites that need to offer large files for download (audio or video, for instance), but also need to enforce access controls by application logic.

In Drupal's case, while a bootstrap is still needed to determine whether to serve a file to the user or not, X-Sendfile avoids unnecessarily tying up the PHP process for the duration of the transfer, which has clear performance and scalability implications.

More information about X-Sendfile:

Thanks to advice from Boris, I've tried to make the patch generic enough so that we could, conceivably, in the future support capabilities such as redirecting file transfers to an FTP server or an Amazon S3-based URL. This ties into some ongoing work related to Darrel O'Pry's filesystem module.

Comments

heshanlk’s picture

See the module that I created http://drupal.org/project/xsend

Heshan Wanigasooriya
Github