Boost your application performance to serve large files!
In order to speed up file-deliveries, one can use the background delivery methods provided by xotcl-core. The main advantage is that with background delivery the costly connection threads are just used for permission checking and locating the file, and the time-consuming spooling of the file to the client is implemented in an asynchronous background delivery thread. Therefore, connection thread are not blocked, it is possible to spool simultaneously several hundred (thousand?) files with only a few connection threads configured.
We use this in production since several years. For example today (no semester yet) we had so far 150.000 file deliveries by background delivery.
The asynchrounous background delivery requires a small patch (2 changes, one is a backport from naviserver) and the tcl thread library (by zoran). The application code is in XOTcl is only a few lines of code and is included in xotcl-core (bgdelivery-procs.tcl).
One needs the following patch to
- aolserver 4.0.10 http://media.wu-wien.ac.at/download/aolserver-nsd-conn.patch, or
- aolserver 4.5.0 http://media.wu-wien.ac.at/download/aolserver45-nsd-conn.patch
The patch is already included in the current head version of aolserver 4.5 and in NaviServer.
With this patch and xotcl-core, one can replace
ns_returnfile 200 $mime_type $filename
by
ad_returnfile_background 200 $mime_type $filename
e.g. in cr_write_content in acs-content-repository/tcl/revision-procs.tcl to activate it and to deliver files from the content-repository (file-store) in the background.
The connection thread is only used for permission management, localization of the file and writing the the reply header, the actual delivery of the file is performed via asynchronous io without using up many resources. This can handle probably a couple of thousand concurrent file deliveries without running out of resources.
Check the files that has been served since the last reboot of your NaviServer/aolserver using this method from the developer support shell:
bgdelivery do set delivery_count
Original thread:
https://openacs.org/forums/message-view?message_id=482221